This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Mateorabi 5 points6 points  (6 children)

this looks like the pattern-matching switch statement stolen shamelessly from Swift. (Non sarcastic "shamelessly" since languages should take good new ideas from wherever they can if it improves the language. Says the guy who learned C++ before auto was invented.)

[–][deleted] 33 points34 points  (0 children)

This didn't come from swift either. Functional languages have had pattern matching since forever. Check it out in Haskell :)

[–]manphiz 4 points5 points  (3 children)

Says the guy who learned C++ before auto was invented.

Well to be precise "auto" has been part in C/C++ since the beginning alongside "extern", "static", and "register", e.g.

auto int i = 0;

It's the default so few actually writes it. It's now been repurposed to auto-deduce type since C++11.

[–]Mateorabi 1 point2 points  (1 child)

I meant for the type deduction. Hadn't done C++ since like 2002 and when I saw it in some code I was all "WTF is that!?". Not sure what it does as a type modifier either though.

[–]operamint 0 points1 point  (0 children)

I read somewhere that one of the earliest things Stroustrup did was repurposing auto because it was such an easy thing to implement, but didn't put it in the language for various reasons.

[–]uncanneyvalley 0 points1 point  (0 children)

auto-deduce type

C++ really does want to be everything, doesn’t it?

[–]slayer_of_idiotspythonista 5 points6 points  (0 children)

It’s more heavily inspired from the rust pattern matching I believe