From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2005-01-06 08:58:00
> Hi Aleksey,
> Currently, Phoenix has local variables, lambda and scopes.
> IMHO, Phoenix-2 has the best syntax yet that satisfies all
> requirements so far:
> Here's the solution to the use-case posed in the email
> exchanges above:
> write a lambda expression that accepts:
> 1. a 2-dimensional container (e.g. vector<vector<int> >)
> 2. a container element (e.g. int)
> and pushes-back the element to each of the vector<int>.
> lambda(_a = _2)
> push_back(_1, _a)
> Since we do not have access to the arguments of the outer scopes
> beyond the lambda-body, we introduce a local variable _a that
> captures the second outer argument: _2. Hence: _a = _2. This
> local variable is visible inside the lambda scope.
Any particular reason why you decided against implicit scoping along
the lines of
for_each( _1, push_back(_1, outer(_2)) )
-- Aleksey Gurtovoy MetaCommunications Engineering
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk