8 ms·
Isn't this just an algebraic data structure?
by verroq 10y ago
Isn't this just an algebraic data structure?
- gpderetta 10y agowell, yes. The nice thing is that in C++ can be implemented purely as a library. Sometimes C++ feels like the high level languages assembler.
- stcredzero 10y agoC++ is what it is. It is "itself." I mean that in the Irish euphemism for moonshine kind of way. C++ is kind of like its own const keyword. It is what it is. const isn't immutability. It's something else. It isn't "pure" -- but it's still pretty darn useful.
- nightcracker 10y agoI have no clue what you're trying to say.
- stcredzero 10y agoMy guess is that you're missing a cultural referent, and you're unused to programming language discussion comments that aren't contentiously positive or negative, but are rather whimsical.
- masklinn 10y ago> The nice thing is that in C++ can be implemented purely as a library. The bad thing is that they suck.
- gpderetta 10y agoThey are certainly nowhere as nice as a builtin language feature, but they are not too bad. They are in fact quite usable. In the next 10 years C++ might even grow another leg and incorporate them in the basic language (together with proper pattern matching).
- Manishearth 10y agoIn languages where they are builtin they get used quite a lot to great effect, whereas this is cumbersome in C++, both with boost and the new std::variant stuff. "usable" might not cut it for something you want to use ubiquitously :) It's good that C++ has this, but it hinders some programming patterns. Of course, C++ has other programming patterns that it's great at to compensate :)
- bjz_ 10y agoUnfortunately that means they lack lots of the pattern matching niceties that you get in languages with builtin ADTs. There is an impressive paper about implementing pattern matching on sub-classes, but it's pretty hackily done using the preprocessor, and could definitely do with some language support: http://www.stroustrup.com/OpenPatternMatching.pdf http://www.stroustrup.com/OpenPatternMatching.pdf
- hellofunk 10y agoIt is widely speculated that pattern matching and many other syntactic enhancements are coming to C++ because of the big door that std::variant has opened.
- deleted 10y ago[deleted]
- squidbidness 10y agoIIRC Stroustrup mentions a desire for features such as these for versions of C++ after C++17.
- MichaelMoser123 10y agoC++11 c++14 c++17 does that mean that we might see a match statement in c++20? It would be a significant addition - similar in complexity to anonymous functions.
- MichaelMoser123 10y agoi remember that Bjarne Stroustrup held a talk in cppcon15 where he talked a lot about the GSL library [1] - it would add type annotations that can be checked by a tool, so as to check for potential memory problems (to me that sounds like a poor man's borrow checker). One year later: i see the template library [1] but i don't see the analysis tool. Does anybody know what happened with this initiative? [1] https://www.youtube.com/watch?v=1OEu9C51K2A https://www.youtube.com/watch?v=1OEu9C51K2A [2] https://github.com/Microsoft/GSL https://github.com/Microsoft/GSL