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 into a map, and using a
function or macro called with-bundle, automatically bind the map's
vals to their respective variables:
  (def my-bundle
    {'*variable-1* :something1, '*variable-2* :something2})

  (with-bundle my-bundle
    (do-stuff))
    ; equivalent to (binding [*variable-1* :something1, *variable-2*
something2] (do-stuff))

(Why don't I just use one overridable variable containing a map?
Backwards compatibility with my library's previous versions, which
already use these multiple variables.)

So is this possible without arcane stuff? In
http://groups.google.com/group/clojure/browse_thread/thread/23fe1a5c9d940976/,
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. So what
should I do—is there anything I can do, other than using only one map
variable?

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to