|
Boost : |
From: Dave Abrahams (abrahams_at_[hidden])
Date: 2000-01-01 20:16:08
> But should that prevent you from pursuing this at all? I think that
> something that supported:
>
> element() += 3
> element() += 3 + x
I don't think we can even support this one right. x might be a reference to
element().
> element() += element()
>
> but didn't support:
>
> element() = element() + 3
>
> would still be quite useful. And it would be good to identify precisely what
> can and can't be done without typeof.
>
> I'd be willing to help complete and refine the expression template, Dave, if
> you decide to start on it.
You know, Python has a limited form of lambda, but turns out to be every bit
good enough. You can't access variables from enclosing scopes, but you can
get values from the enclosing scopes by binding default arguments:
lambda x, y = y_from_enclosing_scope: x + y
It's kind of an ugly hack, but you get used to it, and it's completely
adequate for most uses. I'm afraid C++ just doesn't give us what we need to
make a similar compromise.
[I am utterly unworried about the fact that a bound auto variable's lifetime
would end with its scope even if the lambda function passed out of the
scope. This is absolutely C++-like in every respect and would surprise no
one, unless we insist on using the word 'lambda'. That would make people
expect it to work like lambda does in other languages].
-Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk