The Evolutions of Lambdas in C++14, C++17 and C++20
fluentcpp.com
The Evolutions of Lambdas in C++14, C++17 and C++20
1–10 of 75 posts
Re: The Evolutions of Lambdas in C++14, C++17 and C++20
#2 myLambda = [](&&x){ std::cout
what's the point of having to write auto everywhereRe: The Evolutions of Lambdas in C++14, C++17 and C++20
#3C++23 drop the word auto? myLambda = [](&&x){ std::cout what's the point of having to write auto everywhere
Re: The Evolutions of Lambdas in C++14, C++17 and C++20
#4C++23 drop the word auto? myLambda = [](&&x){ std::cout what's the point of having to write auto everywhere
Re: The Evolutions of Lambdas in C++14, C++17 and C++20
#5C++23 drop the word auto? myLambda = [](&&x){ std::cout what's the point of having to write auto everywhere
As a general preference, I'd always want a keyword to introduce a new variable, and most languages seem to agree even if they didn't have to.
Re: The Evolutions of Lambdas in C++14, C++17 and C++20
#6I wouldn't say it's a smaller evolution than previous iterations.
Re: The Evolutions of Lambdas in C++14, C++17 and C++20
#7C++23 drop the word auto? myLambda = [](&&x){ std::cout what's the point of having to write auto everywhere
syntactical disambiguation, there's already something called "the most vexing parse". C++ is full of little holes like these and getting rid of auto would surely at least double compile times or at worst make parsing C++ actually impossible.
Re: The Evolutions of Lambdas in C++14, C++17 and C++20
#8C++23 drop the word auto? myLambda = [](&&x){ std::cout what's the point of having to write auto everywhere
As seen from Python vs Lua: without a keyword for introduction it's less clear which scope a variable belongs to. Scopes are part of deterministic destruction in C++ and should not be taken lightly. As a general preference, I'd always want a keyword to introduce a new variable, and most languages seem to agree even if they didn't have to.
Re: The Evolutions of Lambdas in C++14, C++17 and C++20
#9Re: The Evolutions of Lambdas in C++14, C++17 and C++20
#10Earlier quoted context omitted.
As seen from Python vs Lua: without a keyword for introduction it's less clear which scope a variable belongs to. Scopes are part of deterministic destruction in C++ and should not be taken lightly. As a general preference, I'd always want a keyword to introduce a new variable, and most languages seem to agree even if they didn't have to.
In this case x must obviously be in a new scope as all function parameters. There isn't possibly be an ambiguity here.
I agree with them, in Python the number of times something like this happens:
myVariable = 10
myVariablr = clever_function(myVariable)
(note the typo in variable name)