Is there any written rationale for direct binding? It sounds like a poor man's inlining, except we already have perfectly good opt-in inlining.
If these screwy semantics are to remain, an absolute minimum courtesy would be for 'binding' to throw an exception at macro expansion time when one tries to rebind a var that matches the direct binding criteria. -Per On Fri, Apr 16, 2010 at 10:51 AM, Phil Hagelberg <p...@hagelb.org> wrote: > On Thu, Apr 15, 2010 at 6:27 AM, Joost <jo...@zeekat.nl> wrote: >> But on the master branches I get: >> >> $ java -server -Djava.net.preferIPv4Stack=true -Dpid=30893 - >> Djava.awt.headless=true -cp /home/joost/lib/clojure/clojure-1.2.0- >> master-SNAPSHOT.jar:/home/joost/lib/clojure-contrib/clojure- >> contrib.jar clojure.main >> Clojure 1.2.0-master-SNAPSHOT >> user=> (use 'clojure.contrib.sql) >> nil >> user=> (binding [clojure.contrib.sql/do-commands #(prn %) >> clojure.contrib.sql/do-prepared #(prn %1 %2)] >> (do-commands "bla")) >> java.lang.Exception: no current database connection (NO_SOURCE_FILE:0) >> >> It looks like I can't bind do-commands... But this works: > > This is due to a little-known feature in the current git master called > direct binding. Basically the value of any var bound to a function > inside any namespace beginning with "clojure" is fixed at compile > time, so there's no way to rebind it. > > It's intended to give a performance boost since the step of var lookup > may be skipped, but it also has the side-effect of making you think > you're going a little crazy if you don't know about it. Unfortunately > right now there's no way to opt-out, though we've discussed some > mechanisms that might allow that in the future. It sounds like it > might get turned back off before 1.2 is released: > > http://www.assembla.com/spaces/clojure/tickets/271-determine-direct-binding-policy-and-controls > > The only workaround right now is to create your own function that > wraps the function you're trying to rebind and rebind your wrapper > instead. > > -Phil > > -- > 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 -- 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