
Boost : 
From: Jörg Striegnitz (J.Striegnitz_at_[hidden])
Date: 20020320 08:22:57
Jaakko Jarvi wrote:
>
> > > I haven't look at any of the technical issues, but from a purely
> > > esthetic view I prefer the familiar, explicit "lambda(x, y, x + y)".
> >
> > Sometimes the choice is not so clearcut.
> >
> > std::for_each(v.begin(), v.end(), std::cout << _1 << '\n');
> >
> > vs
> >
> > std::for_each(v.begin(), v.end(), lambda(x, std::cout << x << '\n'));
> >
> > In general, I find that every nonpurefunctional use looks better with the
> > _N syntax; lambda() implies a pure function as far as I'm concerned.
> >
>
> The difference is really just syntactical.
It isn't because 'lambda' introduces scope. For instance, consider the
nested lambda term
lambda(x,y, lambda(x,y, x + y  x)(y,x) ) (12,3)
It must be clear how to evaluate this term:
12 + 3  12 = 3 vs. 3 + 12  3 = 12 ?
Of course, the latter case is preferable ;)
Ciao
Jörg
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk