Boost logo

Boost :

From: Alexander Nasonov (alnsn_at_[hidden])
Date: 2007-06-28 23:08:16


Daniel Walker wrote:
> Right. Actually, now that I think about it I'm getting a little
> confused about scenarios where this could save you space. I think they
> may be limited.

Scenarios for static stateless lambda expressions are limited, so it's
not a surprise that scenarios where this could save you space are
limited too ;)

We should carefully think about static _stateful_ lambda expressions.
Some lambda expressions contain only constants and these expressions can be
"complied" into static function. Though, it may lead to a confusion when
a user pass a variable (not constant!) but static lambda uses a value
passed first time.

int x = 0;
(_1 + x).get_static_function<int>()(0); // returns 0 - ok
x = 1;
(_1 + x).get_static_function<int>()(0); // returns 0 - bad

Too bad.
I have another use-case where stateful lambda could be useful but
above problem doesn't give it any real chance :-(

-- 
Alexander Nasonov - http://nasonov.blogspot.com
Pennies do not come from heaven. They have to be earned here on
earth. -- Margaret Thatcher --
/---------------------------- Fortune script ----------------------------\
curl 'http://www.quotedb.com/quote/quote.php?action=random_quote&=&=&' | \
    sed -e "s/^[^']*'//;s/.);$/ --/;s/<[^>]*>//g;2s/^.\{17\}//"        | fmt

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