|
Boost : |
From: Reece Dunn (msclrhd_at_[hidden])
Date: 2006-04-14 07:14:05
David Abrahams wrote:
> Valentin Samko <boost_at_[hidden]> writes:
>
> > DA> auto(x){ x->first < 0 }
> >
> > This is quite similar to what we are considering for polymorphic
> > lambdas,
> > <>(x) { return x->first < 0; }
>
> Except 1/3 longer, and, I guess for some people, there's a huge
> difference in aesthetics
Yes. Looking at the current paper by Doug Gregor and others, I
don't like the syntax:
<>( int x ) -> bool { return x == 10; }
It is too different from "normal" function declerations. Dave's
auto(x) is closer and given a choice I would prefer that one.
Lambda functions and expressions should scale well, for example,
in a GUI application:
copy( range( 0, listbox.get_length()) | transform(
auto( item )
{
QtString str;
listbox.get_item_text( item, str );
return std::wstring( str );
}
), v.begin());
where you need to do a conversion inside the lambda function
before returning it.
Here, it might be easier to define that transformation function
externally, but this doesn't work all of the time. It also makes
the code harder to follow if you have a lot of similar functions/
function objects that vary very slightly.
Another example would be manipulating pair/tuple objects and
doing a transform on them before returning from the lambda
function.
- Reece
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk