News for hackers. Stuff that matters.
Re:The Year of C++ Successor Languages by jstimpfle on Monday January 02, 2023 @10:15AM (#34218740)
There are enough practices that handle this problem just fine in various ways. Like, make the function that should be used stand out in an obvious way.

If that is the whole point of constructors, it's the best argument why Rust does not have them. Programming is chock-full of "this must be called only by that or in this or that context..." and practically speaking, only a part of them can be handled by language objects and construct/deconstruct semantics.

Plus, C++ gives enough escape hatches to get not-constructed objects or to un-construct objects without them going out of scope. The "guarantees" provided by C++ that require a ton of baggage like ridiculous initializer lists or 17 different kinds of constructors (to the point where it's sometimes almost impossible to tell which will be called), or requiring an out-of-band mechanism (exceptions) to signal construction failure.... are simply not worth it in my book.

There are no comments on this comment yet.