@nogc and Exceptions
Guillaume Piolat
spam at spam.org
Thu Sep 29 23:35:51 UTC 2022
On Thursday, 29 September 2022 at 12:12:34 UTC, Quirin Schroll
wrote:
> There’s a few options:
> * Ignore the issue at a language level and just lie (code
> below): Make an `Exception` allocating function and cast it to
> `@nogc`. I do not know if that is UB.
> * Make `@nogc` not apply to a `Throwable` allocated in a
> `throw` expression.
> * Introduce Yet Another Damn Function Attribute (YADMA)
> `@nogcUnlessThrown`.
>
Why not allow to throw an immutable(char)[] value instead of
Exception?
No destruction, allocation, and @nogc, and no DIP 1008 needed.
And it's usually enough for errors.
It would break chaining I guess.
Breaking the type system (@nogc) breaks D programs without
runtime, or an impaired runtime. For sure one can rewrite it all
with error codes, but well.
More information about the Digitalmars-d
mailing list