Hi, On Aug 10, 9:10 pm, jvt <vincent.to...@gmail.com> wrote:
> Be this as it may, you can still get weird run-time behavior from this > kind of macro in the following situation: > > (def *v1* 10) > (def var-map {:*v1* 100}) > (def wrong-map {:*v2* 10}) > > (with-bindings-from-map var-map (+ v1 100)) ; -> 200, does what we > expect > (with-bindings-from-map wrong-map (+ v1 100)) ; -> 110, does the > wrong thing entirely, silently The map actually takes the Var itself as key. (def wrong-map {#'*v2* 10}) already blows up, if *v2* does not exist. If it does exist, we are in the same situation you have when the key is not present in the map. But in this situation we are all the time: (:some-key a-map). You type by accident (:sone-key a-map) and maybe don't notice it until strange things happen, because the value of ":some-key" is suddenly nil. If you are concerned about this, you can always add your function on top of the proposed low-level API to add all safety-checks needed. While at the moment this is not possible at all... > Plus, this doesn't depend on a how the compiler implements or > optimizes names. It could be that in the future clojure will want to > use a different representation internally than maps for symbol->value > translation. No. It is already independent of the Compiler. The map is just used to transport the mapping to the Compiler. What he does internally with the map is completely independent of that fact. He may use the map directly or do some further magic to it. The only hacky point is that Var/pushThreadBindings is not a public API up-to-now. But Rich already stated his wish to slate this into a Clojure API via push-thread-bindings. Sincerely Meikel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---