Boost logo

Boost :

Subject: Re: [boost] Template metaprogramming libraries
From: Larry Evans (cppljevans_at_[hidden])
Date: 2011-09-11 09:22:26

On 09/11/11 02:30, Jeffrey Lee Hellrung, Jr. wrote:
> On Sun, Sep 11, 2011 at 12:01 AM, Ábel Sinkovics <abel_at_[hidden]> wrote:
>> Hi Larry,
>>> Are you saying that using the existing mpl, one cannot embed
>>> lambda expressions inside other lambda expressions? Is that
>>> mpl problem an example of name capture:
>>> ?
>> You can embed MPL lambda expressions inside other ones. I couldn't find
>> a way of accessing the arguments of the outer lambda expression from the
>> inner one, because the names _1, _2, etc were referring to the arguments
>> of the inner expression, not the outer one (they were shadowing the
>> outer ones).
>> I'd express it with "\x.\x.x" in lambda calculus. Inside the inner
>> lambda abstraction "x" refers to the argument of the inner, not the
>> outer one.
> A while ago someone suggested (on the developers' list) adding de Bruijn
> indices [1] to Boost.Bind and/or Boost.MPL (and may have provided at least a
> sample implementation for one or the other, I'm not sure),

I attempted an implementation, but was not successful, as indicated in
this post:

> which ( I think) would allow you to do what you want to do.
> There might be some protect and bind combination of contortions to do what
> you want, but I'd certainly agree that, even if it could be done, it
> probably wouldn't be pretty.

I remember doing something with those templates to workaround a problem
that *seemed* like it was a name capture problem; so, I'd agree with
Jeffrey here that it might work with some combination of bind protect
(I also think I used lambda).

> [1]
> - Jeff
> _______________________________________________
> Unsubscribe & other changes:

Boost list run by bdawes at, gregod at, cpdaniel at, john at