3 ms·
> the core language is mostly sound, simple intuitive and performant I wouldn't say so. Even object initialization is atrociously complex in C++. https://stac
by MaxBarraclough 6y ago
> the core language is mostly sound, simple intuitive and performant
I wouldn't say so. Even object initialization is atrociously complex in C++.
https://stackoverflow.com/a/620402/ https://stackoverflow.com/a/620402/
https://stackoverflow.com/a/54350350/ https://stackoverflow.com/a/54350350/
- quietbritishjim 6y agoOr move semantics including rvalue references. In retrospect, objects should have been moved by default (and destructors for moved-from objects not called), like Rust. Then copying can just be an explicit normal method (that returns its result by moving it!).
- Veedrac 6y ago> and destructors for moved-from objects not called This doesn't work entirely cleanly in cases the compiler can't track liveness, which is more of an issue for C++ than Rust, since you want to be able to move out of pointers. A simple solution is to replace move operators with an `invalidate` function the compiler calls after doing a shallow move, that sets the old value to a moved-from state. Copy constructors (as opposed to copy assignment operators) are already a fine way to copy a value, there's no real need to change that.
- deleted 6y ago[deleted]
- Asooka 6y agoObject initialisation complexity is a consequence of the design goals of C++. It's unavoidable complexity, but it's not surprising once you know about it, and it is required for consistency.
- leni536 6y agoIt's also a consequence of some unfortunate mistakes, like uniform initialization being screwed up by std::initializer_list.
- MaxBarraclough 6y ago> it's not surprising once you know about it I disagree. My first link shows subtle but important differences across versions of C++, and it is surprising. It's a foot-gun at the heart of the language. I agree with the author's comment: This is one of the dusty corners of C++ that can drive you crazy.