Re: binding and bundles of variables

2009-08-10 Thread Meikel Brandmeyer
Hi, On Aug 10, 9:10 pm, jvt 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

Re: binding and bundles of variables

2009-08-10 Thread samppi
I'm also concerned about the implementation, which seems to rely on what appears to me to be a little magical. An alternative that I was considering was to just break backwards compatibility and combine all of the variables into one variable containing a map in a new major version of my library. B

Re: binding and bundles of variables

2009-08-10 Thread jvt
Really, this should be (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 Anyway, you may want to think about why common-lisp does not have a with-all-slots macro for use

Re: binding and bundles of variables

2009-08-10 Thread jvt
Meikel, What concerns me is that this macro lets you write code which depends on names which are not present at compile time (someplace). Coming from scheme, not only would you _not_ do this, but you _can't_ do it without using eval in your macro body, which is considered bad form. That we can d

Re: binding and bundles of variables

2009-08-10 Thread Niels Mayer
On Thu, Aug 6, 2009 at 10:12 PM, samppi wrote: > > I have about six variables that are often rebound together using > binding; these variables are used to access and set data in a state > object (whose type is of the user's choice). These variables' values > (the accessors and setters) are often

Re: binding and bundles of variables

2009-08-09 Thread Meikel Brandmeyer
Hi, Am 10.08.2009 um 03:24 schrieb jvt: (defmacro with-a-b-c [m & body] `(let [mp# ,mp] a (:a mp#) b (:b mp#) c (:c mp#)] ~...@body)) Is this a more "idiomatic" solution or a more "lispy" one, or am I laboring under a misunderstanding? I find this not very elegant. Tomorrow you need b, c and

Re: binding and bundles of variables

2009-08-09 Thread jvt
When I encountered this post, my instinct was to suggest that he write a specific macro to bind these particular variables rather than depend on magic to make new bindings at run-time from symbols known only at run-time, a la: (defmacro with-a-b-c [m & body] `(let [mp# ,mp] a (:a mp#) b (:b mp#)

Re: binding and bundles of variables

2009-08-08 Thread John Harrop
On Sat, Aug 8, 2009 at 9:52 AM, Rich Hickey wrote: > > On Sat, Aug 8, 2009 at 5:53 AM, Meikel Brandmeyer wrote: > > Hi, > > > > Am 08.08.2009 um 02:52 schrieb samppi: > > > >> Great, thanks. Is clojure.lang.Var/pushThreadBindings a public, > >> supported part of the API? Can I use it without fear

Re: binding and bundles of variables

2009-08-08 Thread Meikel Brandmeyer
Hi, Am 08.08.2009 um 15:52 schrieb Rich Hickey: get-/push-/pop-thread-bindings wrapping Var.get/push/popThreadBindings would be a welcome issue/patch. Note the addition of getThreadBindings(), which returns a map of all the current bindings. This could be used to define a function-returning ma

Re: binding and bundles of variables

2009-08-08 Thread Rich Hickey
On Sat, Aug 8, 2009 at 5:53 AM, Meikel Brandmeyer wrote: > Hi, > > Am 08.08.2009 um 02:52 schrieb samppi: > >> Great, thanks. Is clojure.lang.Var/pushThreadBindings a public, >> supported part of the API? Can I use it without fear of suddenly >> dropped support? > > It is was `binding` uses intern

Re: binding and bundles of variables

2009-08-08 Thread Meikel Brandmeyer
Hi, Am 08.08.2009 um 02:52 schrieb samppi: Great, thanks. Is clojure.lang.Var/pushThreadBindings a public, supported part of the API? Can I use it without fear of suddenly dropped support? It is was `binding` uses internally. Unfortunately this is not exported by Clojure's public API. I - unf

Re: binding and bundles of variables

2009-08-07 Thread samppi
Great, thanks. Is clojure.lang.Var/pushThreadBindings a public, supported part of the API? Can I use it without fear of suddenly dropped support? On Aug 6, 10:56 pm, Meikel Brandmeyer wrote: > Hi, > > On Aug 7, 7:12 am, samppi wrote: > > > So is this possible without arcane stuff? > > Inhttp:/

Re: binding and bundles of variables

2009-08-06 Thread Meikel Brandmeyer
Hi, On Aug 7, 7:12 am, samppi wrote: > So is this possible without arcane stuff? > Inhttp://groups.google.com/group/clojure/browse_thread/thread/23fe1a5c9..., > I asked about using a macro to do this, and the consensus seems to be > that it's possible with magic, but it's generally a bad idea.

binding and bundles of variables

2009-08-06 Thread samppi
I have about six variables that are often rebound together using binding; these variables are used to access and set data in a state object (whose type is of the user's choice). These variables' values (the accessors and setters) are often used together. I'd like to be able to bundle these values