6 ms·
In-line class static variables ... finally. if constexpr is neat (along with a bunch of the other constexpr/compile-time features that have been coming along),
by cmrdporcupine 3y ago
In-line class static variables ... finally.
if constexpr is neat (along with a bunch of the other constexpr/compile-time features that have been coming along), but I feel like this will have both... good and bad uses, and I fear for the astronauts who will go crazy with this.
The enhanced conditionals, this I kind of like though it would take some while to get used to... kind of surprised this got in, being such a departure from C.
Small thing: hardware_destructive_interference_size is nice. Wish I had this in Rust.
Looks like it was asked for (https://github.com/rust-lang/rfcs/issues/1756 https://github.com/rust-lang/rfcs/issues/1756) but went nowhere.
- gumby 3y ago> kind of surprised this got in, being such a departure from C. While completely gratuitous incompatibilities with C are not welcome, C compatibility in general was abandoned in new features long ago (consider range based `for` or the venerable `nullptr`).
- AlotOfReading 3y agoI have a strong dislike for the enhanced conditionals. Like, the feature itself is fine... but there's just a certain subset of people who think any new C++ feature is the blessed "proper" way to accomplish any task and this feature is very abusable. It also doesn't provide very much benefit to actual practice in return.
- secondcoming 3y agoHaving the compiler deduce the return type of a function depending on the constexpr path taken is really useful.
- AlotOfReading 3y agoDifferent feature, I'm talking about the optional initialization section added to conditionals. It allows moving declarations to the point of use like for statements. I've also met people who think it's now the appropriate place to declare all block scope variables, which is horrifying.
- cmrdporcupine 3y agoIt's horrifying but maybe also intriguing? Has shades of the OCaml/StandardML "let ... " scope: StandardML: let val a = 1 val b = 2 in a + b end It's nice for making it clear that the scope of the assignment is restricted to this lexical scope, though there are other ways to do this in C/C++. I work in Rust these days so haven't had a chance to use much of this, but I wonder if this has some nice RAII type use patterns? I may now go explore.
- einpoklum 3y ago> I have a strong dislike for the enhanced conditionals. So don't use them. C++ is a multi-paradigmatic language, you don't have to (and typically can't, really) put all features to use. I'm not such a great fan of them either, but it's not like they would confuse me if I saw them in somebody else's code. https://www.youtube.com/watch?v=cWSh4ZxAr7E&list=TLPQMjkwNTIwMjMyIm3XvhQtpQ&index=2 https://www.youtube.com/watch?v=cWSh4ZxAr7E&list=TLPQMjkwNTI...
- AlotOfReading 3y agoFor some additional context, this came up for me because some other team had snuck verbiage into our style guide that mandated things like this instead of traditional initializers: void foo() { if (auto [a, b, c] = std::make_tuple(x, y, z); true) { /* [...] */ } } Yeah you can still read this, but it's stupid to support constructs creating scope, doing control flow, and initializing arbitrarily many variables simultaneously (which may invoke constructors of their own). The relatively minor benefits to things like iterators are not outweighed by the burden of supporting this stupid code.