throw immutable - Re: The D standard library is built on GC, is that a negative or positive?

Nick Treleaven nick at geany.org
Thu Dec 15 19:49:39 UTC 2022


On Thursday, 15 December 2022 at 13:45:03 UTC, Adam D Ruppe wrote:
> 1) `immutable` is ignored on exceptions. The implementation 
> casts it away internally as it is thrown, so when it is caught, 
> it is mutable again. If someone tried to actually modify it at 
> this point, it is undefined behavior. (in this case i think the 
> implementation would just retain the edits for another call to 
> the same enforce msg, T arguments)

I was thinking to add a disabled default constructor for 
Throwable:

     @disable immutable this();

But then every subclass of Throwable has to do the same. What if 
subclasses inherited a disabled constructor - that might solve 
the problem?


More information about the Digitalmars-d mailing list