Subject: Re: phoenix lambda-lambda for_each example
From: Jaakko Jarvi <[email-masked]>
To: Joel de Guzman <[email-masked]>
Cc: Noah Stein <[email-masked]>, David Abrahams <[email-masked]>, Aleksey Gurtovoy <[email-masked]>
Date: Wed, 3 Mar 2004 23:13:38 -0500 (EST)

> Honestly, I still prefer the "outer" approach. Upon inspection,
> the example we are using is flawed. Let me start again with
> a problem: I want to push_back x to all sequences in v when
> calling a lambda-function f:
>
>      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. 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. 1) You'll have to declare the place-holders.
> 2) The syntax does not look like a c++ function call.

I'd think that we'd have two sets of predefined placeholders:
_1, _2, ... for scoped placeholders,
abs_1, abs_2, ... for absolute placeholders,
so the burden of declarations would not necessary be that bad.

This was just to point out something for fair comparison,
I think I find Joel's suggestion more appealing.
One can't get much more concise.

One more point...
In Joel's suggestion, basically all arguments
on parameter slots  expecting  a function object will be
interpreted as lambdas. It first seemed a bit scary that this
information is only at the defintion of the function that is being
called and there is no visual clue at the call site
where the boundaries of lambdas are. But after pondering this
for a while, it worries me less.
In any case, if one gets things wrong, it's very unlikely
that the code compiles.

  Jaakko