Subject: Re: phoenix lambda-lambda for_each example
From: David Abrahams <[email-masked]>
To: Joel de Guzman <[email-masked]>
Cc: Noah Stein <[email-masked]>, [email-masked], Aleksey Gurtovoy <[email-masked]>, Jaakko Jarvi <[email-masked]>
Date: Wed, 03 Mar 2004 10:47:30 -0500

Joel de Guzman <[email-masked]> writes:

> David Abrahams wrote:
>
>> Joel de Guzman <[email-masked]> writes:
>> 
>>>I thought about that too. Upon meditation, I realized it is
>>>not necessary. In this case, Phoenix has scope! That's why I
>>>wrote the title "lamda-lambda". Consider:
>>>
>>>     std::vector<std::vector<int> > v;
>>>     ...
>>>     for_each(arg1, for_each(arg1, cout << arg1 << ' '))
>>>     (v);
>>>
>>>* The first arg1 gets a std::vector<std::vector<int> >
>>>* The second arg1 gets a std::vector<int>
>>>* the third arg1 gets an int.
>>>
>>>Each lambda has its own scope. Try the attached example, if you
>>>are not convinced.
>> I'm not saying that I don't believe it can be done.
>> I'm saying that there's an inherent ambiguity and you need some way to
>> represent the other semantics, where v gets substituted for arg1
>> everywhere.
>
> I don't see it as inherently ambiguous. It's simple to explain
> and visualize that a new scope is introduced anywhere a lambda-
> function is required:
>
>      for_each(c, lambda)

Giving that explanation is one way of resolving the ambiguity, but
then you still need some mechanism to get the other semantics.
Currently you seem to be exploring the use of "outer".

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com