Meikel and All,

On the general topic of the recent posts on the "Clojure Scoping Rules"
thread:

bound-fn is very nice, but I've found that capturing *all* dynamic vars is
often overkill.

In fact, I would argue (subject to persuasion otherwise) that capturing all
dynamic vars should be the very rare exception rather than the rule. In most
cases, it seems to me that a developer should capture just the dynamic vars
that he or she has defined in that particular app, allowing other dynamic
vars to reset in new threads as they otherwise would. Another library might
expect this resetting of its dynamic vars, or the user might expect it of
Clojure's default bindings.

Have you thought about a version of bound-fn in which the user can specify
which specific dynamic bindings to capture?

(bound-fn-with [*binding1* *binding2* ...] [args ... ] <body>)

It would just be shorthand for the following code.

(let [binding1 *binding1* binding2 *binding2* ... ]
  (fn [args ...]
    (binding [*binding1* binding1 *binding2* binding2 ... ]
      <body>)))

I use that code enough that I'm getting tired of writing it out. (No, I
don't think I'm overusing dynamic vars. Even when I use them very
judiciously that piece of code turns up enough to warrant, I think, its own
macro.)

Analogously there could be a bound-lazy-seq-with (or whatever name) for
defining lazy seqs bound over dynamic vars.

Garth

On Mon, Nov 23, 2009 at 3:21 PM, Graham Fawcett <graham.fawc...@gmail.com>wrote:

> On Sat, Nov 21, 2009 at 4:37 PM, Meikel Brandmeyer <m...@kotka.de> wrote:
> > Hi,
> >
> > Am 21.11.2009 um 05:22 schrieb Mark Engelberg:
> >
> >> Which reminds me, every once in a while I see people talking about
> >> this here, and brainstorming up some alternatives to binding that
> >> might interact better with lazy data structures.  Has there been any
> >> real progress on this, or has every proposed solution been equally
> >> problematic?
> >
> > I wrote up a little blog post on the problem and the possible solutions.
> > Feedback welcome.
>
> Very nice. A generalized version might be more useful to your readers:
> take an input seq, and return an output seq which is evaluated
> stepwise in the binding environment.
>
> Best,
> Graham
>
> --
> 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<clojure%2bunsubscr...@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

Reply via email to