In python, lambda usage extremly beautiful. Also, 'lambda' keyword solves readibility problem. I expected a keyword. Is there any challenge to add keyword?
I don't like that in python you are enforced to only use a single expression in lambda. Sure, writing long lambda functions is ugly but I don't think python should enforce a given coding style in the language level.
C++14 lambda tutorial
11–20 of 32 posts
Re: C++14 lambda tutorial
#12In python, lambda usage extremly beautiful. Also, 'lambda' keyword solves readibility problem. I expected a keyword. Is there any challenge to add keyword?
I don't like that in python you are enforced to only use a single expression in lambda. Sure, writing long lambda functions is ugly but I don't think python should enforce a given coding style in the language level.
Re: C++14 lambda tutorial
#13In python, lambda usage extremly beautiful. Also, 'lambda' keyword solves readibility problem. I expected a keyword. Is there any challenge to add keyword?
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.
#define lambda []
?
Re: C++14 lambda tutorial
#14Re: C++14 lambda tutorial
#15Earlier 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 [] ?
If you're going to write C++, then write C++. Don't redefine language constructs to fit the patterns of your other favourite language.
Re: C++14 lambda tutorial
#16Am I wrong or misunderstanding? I'm not saying completely but I feel like when I have used Templates I can now use this.
Re: C++14 lambda tutorial
#17I've never been a good at Templates. After reading this it seems that a lot of Template uses can be replaced with the generic lambdas using auto as the types going in. Am I wrong or misunderstanding? I'm not saying completely but I feel like when I have used Templates I can now use this.
Re: C++14 lambda tutorial
#18I work as a C++ developer, but damn, C++ has the ugliest lambda syntax ever.
Re: C++14 lambda tutorial
#19Earlier quoted context omitted.
I don't like that in python you are enforced to only use a single expression in lambda. Sure, writing long lambda functions is ugly but I don't think python should enforce a given coding style in the language level.
Isn't that literally a core principal of Python? They enforce all kind of coding styles within the language, not the mention all the PEPs.
Re: C++14 lambda tutorial
#20I've never been a good at Templates. After reading this it seems that a lot of Template uses can be replaced with the generic lambdas using auto as the types going in. Am I wrong or misunderstanding? I'm not saying completely but I feel like when I have used Templates I can now use this.
For a more concrete example that doesn't rely on the "authority" of an externally developed template library, consider that templates are also useful for static/compile-time polymorphism (see: Curiously Recurring Template Pattern).