Subject: Re: phoenix lambda-lambda for_each example
From: Joel de Guzman <[email-masked]>
To: David Abrahams <[email-masked]>
Cc: Noah Stein <[email-masked]>, [email-masked], Aleksey Gurtovoy <[email-masked]>, Jaakko Jarvi <[email-masked]>
Date: Wed, 03 Mar 2004 23:28:21 +0800

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)

-- 
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net