Affects Version/s: None
Fix Version/s: None
CLJS-398 was a first attempt to implement an operation to extend single instances, but it fell short because it offered no control over which closures to attach onto the object (i.e. allocates every time). Also, specify is a much better name than extend-instance.
extend-type can be implemented in terms of specify (by specifying the .prototype), but extend-type has grown from its humble beginnings
to an monster of complexity
Currently it does
- print warnings
- optimize IFn impls
- special case the Object "protocol"
- special case js builtins
and all that in a single macro body. So this is also a good opportunity to do some refactoring.
specify should have an interface similar to extend-type. Additionally a lower level operation is needed to attach existing lambdas as protocol methods. It's called specify* in my current implementation. It takes a lambda for every specified protocol-method-arity, with a syntax loosely based on clojure.core/extend.