> I think the question is whether ClojureScript needs to support bound-fn at all. But maybe it really is useful in a single-threaded environment! :)
I'm already finding it very useful for an experimental UI framework design I'm working on. I have a dynamically bound "insert pointer", such that UI views are functions which can be re-run automatically and "emit" dom elements into the tree at the point they were dynamically bound. My defview macro checks which arguments are IWatchable and triggers an inplace dom re-render when the arguments change. I'd also like to use the analyzer to look for deref calls, instead of just arguments, so I can get much more finely grained change notifications. In particular, data can be pushed from the server and trigger an asynchronous re-render, which needs to have the insert pointer and other bindings. > Your implementation will likely be *dramatically* slower Hence why it only applies to ^:dynamic variables. There are generally pretty few of these in any application. I do, however, plan to add an additional way to trigger it for non-dynamic variables, if you want IWatchable support, etc. Probably a ^:var metadata attribute. {^:var false, ^:dynamic true} would be disallowed. Also, the implementation has numerous optimization opportunities, manly centered around using native JS objects instead of ObjMap. > Also this seems like yet another breaking ClojureScript change. The two breaking changes I can see: 1) binding macro - I'm re-using the native Clojure `binding` macro, but could write a custom one which is backwards compatible. With our without a warning configuration. - The behavior I have implemented matches JVM clojure: You can only use binding on Vars labeled as ^:dynamic - Fixing usages is as simple as adding ^:dynamic to the vars you are binding over. - The binding macro behavior in master is actually with-redefs, so that could be subbed in as well. - All and all, a pretty minimal breaking change with easy resolutions 2) ^:dynamic vars exposed to external code must now be accessed with deref - This is extremely minor because Clojure JavaScript libraries are generally the bottom of the stack. If you need interop, you can easily create an additional var, or choose with-rdefs instead. - I haven't currently implemented with-redefs because it would require the analyzer be used to differentiate "raw" vars or vars wrapped in my Var implementation. However, still pretty straight forward. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en