Subject: Re: phoenix lambda-lambda for_each example
From: David Abrahams <[email-masked]>
To: Joel de Guzman <[email-masked]>
Cc: Noah Stein <[email-masked]>, Aleksey Gurtovoy <[email-masked]>, Jaakko Jarvi <[email-masked]>
Date: Thu, 04 Mar 2004 07:56:31 -0500

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

>      f(v, x);
>
> The lambda expression, using outer, is:
>
>      for_each(_1, push_back(_1, outer(_2)))
>
> I honestly find nothing confusing here. I actually see it as simple
> and elegant. 

Agreed, but...

> Compare this with the alternate scheme:
>
>      absolute_argument<1> v; // need to declare
>      absolute_argument<2> x; // need to declare
>
>      for_each[v, x](v, push_back(_1, x))
>
> I really do not find this to be any better than the terse, single
> line lambda expression. 

It will be better for some cases.

> 1) You'll have to declare the place-holders.

Consider this, which I believe can be made to work:

       for_each[_2, _3](_2, push_back(_1, _3))

You may shriek with horror, but I think it's not so terrible.  It does
indicate that we may not need a separate absolute_argument type.  I
think the placement of the []s is strange, though.

> 2) The syntax does not look like a c++ function call.

Not a problem, IMO.

    lambda(x,y)[ for_each(x, push_back(_1, y)) ]

is much better though.

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