Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2006-04-13 17:16:36


Bronek Kozicki <brok_at_[hidden]> writes:

> David Abrahams wrote:
>>>> be templated. I think the syntax should be
>>>>
>>>> auto(x){ x->first < 0 }
>>> where is "return" ?
>>
>> Good observation. Nowhere. Have you got a problem with that? Also
>> no semicolon.
>
> it's not function body, then. It's an expression. C'mon, I do not think that
> this could be honestly called "lambda".

C'mon, haven't you ever heard of something called a "lambda expression?"

Yes, of course it's an expression. We make a provision that a lambda
expression can end with a simple expression in which case that is its
return value. It could be made into a statement and a valid function
body like this:

     auto(x) { x->first < 0; }

but then such a statement normally does *not* return, and the
semicolon adds a little confusion, one more character, and nothing of
value. Adding "return" for the majority of simple lambda expressions
would result in a 25-30% increase in total non-whitespace characters,
which is a big lose.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk