News for hackers. Stuff that matters.
Re:Lambda expression comparison between C++11, C++14 and C++17 by anon946 on Saturday May 14, 2016 @08:03PM (#11698639)
What would you propose as the syntax?
Re:Lambda expression comparison between C++11, C++14 and C++17 by user982 on Saturday May 14, 2016 @08:10PM (#11698659)
Apple extended C with block closures years ago.

  int b = 0;

  ^(int a) {
    return a*b;
  }
The declaration for lambda variables is almost identical to function pointers, just with a ^ instead of a *, so there's nothing to learn (or unlearn, like C++ forces you to). The ^ looks like a lambda, and historically the lambda of lambda calculus actually was a caret accent over the variable. The argument list can be elided.
Re:Lambda expression comparison between C++11, C++14 and C++17 by anon946 on Saturday May 14, 2016 @08:49PM (#11698777)
Looking here (https://developer.apple.com/library/ios/documentation/Cocoa/...) for the details, I think this is going to largely be a matter of opinion. I prefer the C++ syntax, especially when it comes to capture by reference, for which the Apple syntax seems to require the __block storage type modifier.
Re:Lambda expression comparison between C++11, C++14 and C++17 by CJefferson on Sunday May 15, 2016 @03:26AM (#11699892)
And this is why C++ couldn't use this notation, as they didn't want to break compability with this extension of Apple's.
Re:Lambda expression comparison between C++11, C++14 and C++17 by fanf2 on Monday May 16, 2016 @03:34AM (#11704827)
Caret as the embryonic form of lambda is apparently a myth propagated by Barendregt, and lambda is just a random Greek letter to go with alpha, beta, and eta.

http://researchblogs.cs.bham.ac.uk/thelablunch/2016/05/why-i...

Re:Lambda expression comparison between C++11, C++14 and C++17 by optforfon on Sunday May 15, 2016 @03:07AM (#11699846)
I honestly would have much preferred they had a keyword so that it kinda matched the rest of the language. It feels a bit tacked on and hard to parse.

Something like:

lambda(arguments):capture list {...}

Just seems way more clear. Looks more like a function or a class (and a lambda is sort of an in-between kind of thing anyway)