I hate class destructors with a burning passion
Max Samukha
maxsamukha at gmail.com
Wed Jun 9 06:58:26 UTC 2021
On Wednesday, 9 June 2021 at 02:37:34 UTC, Walter Bright wrote:
> On 6/6/2021 4:54 AM, Mathias LANG wrote:
> > https://github.com/dlang/druntime/pull/3476/files
>
> Frankly, the whole jazz with assert() went way off the rails.
> Assert should go directly to Jail, it should not pass Go or
> collect $200. All these layers it goes through is just madness.
>
> Allocating via the GC is in assert is just ridiculous, as the
> program is going to exit shortly anyway. There won't ever be a
> need to run a collection on it. Just malloc away and
> fuggeddabootet.
>
> These sorts of things are why I added the checkaction switch to
> bypass it and just do the simple, direct stuff.
>
> ---
>
> Throwing constructors is one of those things that makes a
> program very hard to reason about.
Placing (part of) constructor logic into a separate function that
may throw, and pretending that a partially constructed state is a
valid state - why do you think it is better?
> There's not a single throwing constructor in DMD, and it's
> going to stay that way :-)
>
Yeah, because they are not constructors. I bet you either
construct lazily when a throwing public method is called, or
require an explicit call to a throwing pseudo-constructor.
More information about the Digitalmars-d
mailing list