
On Tue, Mar 09, 2004 at 03:32:02PM +0100, Gabriel Dos Reis wrote:
David Abrahams <dave@boost-consulting.com> writes:
<snip>
| labmbda x,y: x+y | | It'd be nice if we could get to something that simple.
Yes, and it is one the simplest common cases. The correspnding formulation in C++ would be as simple as well, e.g.
(auto x, auto y) { x + y; }
(three months ago, Bjarne showed another candidate: { x, y; | x + y; })
The main issue in this discussion, however, concerns what to do when a reference is made to an automatic variable in an enclosing scope.
Older versions of python do this: z = 155 fxn = lambda x, y=z: x+y fxn(2) # returns 157 In seem to remember that newer versions have a form of closuring. How about: int z = 155; (auto x, auto y=z) { x + y; } It's not the greatest syntax, and it's often pretty annoying, but I think it's a tad more readable than the proposed. Best, -- Shannon Stewman | Let us walk through the waning night, Caught in a whirlpool, | As dawn-rays tickle our toes, the dew soothes A quartering act: | Our blistered soles, and damp bones stir Solitude or society? | As crimson cracks under the blue-grey sky.