Earlier quoted context omitted.
Not shown in this article are all the things you can do within the [] (typically just [&] or [=]), which turns a simple lambda into a closure. The syntax is a bit arcane, but it does what it needs to. They could've stuck a "lambda" keyword in front of it all, but it's not necessary, and making a new keyword always has the potential to break old code.
is it possible to do #define lambda [] ?
C++14 lambda tutorial
31–32 of 32 posts
Re: C++14 lambda tutorial
#32Earlier quoted context omitted.
Do you have an alternative suggestion? It seems reasonably straightforward to me and I don’t find it all that impossible. Not having to muck around with a specific lambda() factory-like function with horrible inputs (as is needed in LPC where I sort-of learnt to code) is a plus :)
I don't mind C++'s lambdas, but in some other languages they use "arrows", like square = (x) -> x * x C++ won't want to give up the different kinds of capturing, though, so it's hard to see anything much better than what's available now. In imaginary, never-to-be-implemented language daydreams I toy with the idea of using curly braces and implicit positional arguments to have lambdas look like square = { _1 * _1 } an…
Your mockup code sure looks like Lua.