Live data from Hacker News

C++14 lambda tutorial

solarianprogrammer.com

1–10 of 32 posts

Re: C++14 lambda tutorial

#3

In python, lambda usage extremly beautiful. Also, 'lambda' keyword solves readibility problem. I expected a keyword. Is there any challenge to add keyword?

Backwards compatability. Old valid code should remain valid. That includes code which calculates wavelengths.

Re: C++14 lambda tutorial

#4

In 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.

Re: C++14 lambda tutorial

#6
post #3

In python, lambda usage extremly beautiful. Also, 'lambda' keyword solves readibility problem. I expected a keyword. Is there any challenge to add keyword?

Backwards compatability. Old valid code should remain valid. That includes code which calculates wavelengths.

An interesting example of C++ not being able to introduce new keywords is the co-opting of auto in C++11 from a storage class to type deduction.

Re: C++14 lambda tutorial

#7
post #3

In python, lambda usage extremly beautiful. Also, 'lambda' keyword solves readibility problem. I expected a keyword. Is there any challenge to add keyword?

Backwards compatability. Old valid code should remain valid. That includes code which calculates wavelengths.

[deleted]

Re: C++14 lambda tutorial

#8
post #3

Earlier quoted context omitted.

Backwards compatability. Old valid code should remain valid. That includes code which calculates wavelengths.

An interesting example of C++ not being able to introduce new keywords is the co-opting of auto in C++11 from a storage class to type deduction.

But they had a decent justification: the auto keyword literally did nothing in C++. The only place it was valid, it was also the default.

Re: C++14 lambda tutorial

#9

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.

Re: C++14 lambda tutorial

#10

As someone currently learning C++ the biggest surprise was finding out about C++11/14. I'd assumed that the language hadn't changed for decades so it's great to see it still being updated.

Yes. C++ is in an active standard update process. Here is a short history of notable versions:

Year Version Year-Delta

1983; 1.0; 0

1989; 2.0; +6 years

1998; C++98; +9 years (first ISO standard)

2003; C++03; +5 years (minor update)

2011; C++11; +8 years (major update)

2014; C++14; +3 years (minor update)

The C++14 version was the first that arrived on schedule. The next major version is planned for 2017. The future looks quite promising for C++.

Post reply on HN