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

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

> Noah Stein wrote:
> >     for_each(arg1, push_back(seq, arg1) )(v1,seq(v2));
> >     for_each(arg1, push_back(seq, arg1) )(v1,seq=v2);
> >
> > It might not be possible to get the above syntax to work.  I think there
> > might be a convoluted method to get it to work that doesn't require
run-time
> > overhead.  Unfortunately it would dramatically complicate the
> > behind-the-scenes code.
>
> Remember that we do not have control over the invocation
> (function call) of the lambda. The rightmost parens are
> not part of the lambda.

I figured we didn't have that capability currently.  My suggestion was to
add the functionality to support having the invocation parameters optionally
support certain the proposed construct.  The need to discriminate between
"regular" and "scope-bound" parameters is the "convoluted method" I was
trying to communicate.  I think it's possible functionality.  I'm not
certain its worth the effort and convolution of the library code.

I like the thought that the user code could be much cleaner.  The scoping
mechanism is much less intrusive on user code visually than the lambda
example.  It is only apparent when used.  I also like that no matter how the
"topology" of the nested scopes changes, the references never change (unlike
outer<2> that might need to change to an outer<3>).  And if properly
implemented, I think it can be done with little to no runtime overhead (in
release mode).

Unfortunately, I think it would most likely require a large-scale change
inside the guts of the system.  I think the change will greatly complicate
the codebase and be nearly incomprehensible to the average user.  If that
issue is of great concern (and I know it can be), I support the idea of
outer<n>.

-- Noah