Proposal: Exceptions and @nogc

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sat Apr 1 22:49:42 PDT 2017


On 4/1/2017 10:29 PM, rikki cattermole wrote:
> 1) What if an exception dtor throws (yuck but eh)?

That's treated as a new exception.

> 2) Could this in some form be paired with allocators? e.g.
> typeof(this) dup(IAllocator) { ... }
> throw new MyException(8); versus throw alloc.make!MyException(8);

I don't see a purpose for a custom allocator with this. The exception objects 
will be totally owned by the druntime EH implementation.

> 3) Do we really need to copy an exception before rethrowing? It seems overkill,
> couldn't we introduce a new local variable to determine if it should free or not?

The vast majority of use cases would be:

     throw new ExceptionType;

which is detected by the compiler and the copy doesn't happen. For the rest of 
the (presumably) rare cases, an extra copy will be insignificant, and has the 
advantage of simplicity.

> And as probably expected, DIP please. Its a big set of changes and warrants
> documenting in that form.

If it survives the n.g. discussion I will. Though the DIP process is in limbo at 
the moment since Dicebot is no longer running it.


More information about the Digitalmars-d mailing list