On Fri, Mar 27, 2009 at 10:06 AM, hjlee <hj.d....@gmail.com> wrote:

>
> Hi, all.
>
> Story:
> I couldn't understand my "binding" form behavior.
>
> (binding [*print-level* 2 *print-length* 2] (some-function))
>
> but, some outputs didn't confirm the bound value.
>
> After some investigation on my code and output, I found the reason.
>  - I used pmap
>

> Well, I can use "set!", but I think that's not a solution.
> I could "set!" *print-level* and *print-length.
> But I couldn't "set!" other defs defined in other ns.
> (I guess that's not intended use of "set!". right?)
> And think about something like *out*.
>

You could always propagate the bindings like so:

(binding [*print-level* 2 *print-length* 2] (some-function *print-level*
*print-length*))

Or write a wrapper function that takes the binding values, rebinds them, and
calls some-function. Of course, doing so seems like it exposes a leaky
abstraction. You wouldn't necessarily expect that you'd have to write it one
way for map and another for pmap, but maybe it is just a case of "programmer
beware."


Paul

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