by baybal2 · 5y ago · 0 comments
The insanity really began when attempt to further formalise, and narrowly specify the language revealed glaring gaps of the basic spec, and a decade+ period of haphazard fixes to the standard started.
C++98 had the same value categories (lvalue and rvalue) as C, but already more complex interactions between these and various other language features, because of references if nothing else.
Then, C++ has not one but two kinds of pointers - C-style pointers and references, which each interact with other languages differently.
C++ has the most complex function overloading rules of any language. Made all the more complex by the special interaction between single-parameter constructors and function overloading. Operator overloading adds yet another layer of complexity, being slightly different than function overloading rules.
C++ has exceptions and destructors and special interactions between them. Exceptions also interact with the reference and type specifier system in complex ways. C++98 even had exception specifiers which also have interactions with the type system in general.
C++ has templates, with the myriad complex rules for their syntax (e.g. the little known second meaning of the keyword "template"), for name resolution inside template definitions, for template interactions with the linker. SFINAE is also a famously hard to understand rule, that interacts so nicely with overload resolution that it turns the compilation process into a turing-complete language of its own.
C++ has namespaces, which interact with name resolution and thus templates and overload resolution in several ways. In the same vein, it has private, public, protected, and friend, all interacting with name resolution.
C++ supports multiple inheritance, with complex rules for how objects are constructed in the presence of multiple super classes.
C++ has 3 different ways of initializing member variables, with defined interactions between them (in-place, constructor initiator list, constructor body).
C++ inherits C's pre-processor, while adding new ways for it to interact with linkage rules (because of templates, default constructors/destructors).
Still, the cruft accumulates, and I dread the day when the language will become recognizably C++ish. Feels like things are getting out of control already - most C# programmers I've met know/use barely any of the features introduced after C# 6.0. (They're pretty good, though. The features, I mean. But the programmers also)
If you generalize that to variables, you get 18: https://accu.org/journals/overload/25/139/brand_2379