Subject: RE: phoenix lambda-lambda for_each example
From: "Noah Stein" <[email-masked]>
To: "Joel de Guzman" <[email-masked]>, "Noah Stein" <[email-masked]>
Cc: "David Abrahams" <[email-masked]>, "Aleksey Gurtovoy" <[email-masked]>, "Jaakko Jarvi" <[email-masked]>
Date: Wed, 3 Mar 2004 17:55:13 -0800

> From: Joel de Guzman [mailto:[email-masked]]

> 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.

For simple examples, I agree that outer is simpler and cleaner.  For larger
blocks of code with more complex structure the use of outer beyond the
immediately enclosing scope can be much more difficult.  Updating outer<2>
to outer<3> in all instances that need it when a scope changes could
theoretically be problematic.  If, however, most code blocks are not that
large and do not contain much nesting, this is a non-issue.  How large and
complex do you expect lazy code blocks?  If they don't reach much beyond
your example then I'd be fine going with outer.

-- Noah