Plan for Exceptions and @nogc?

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 18 12:47:35 PST 2015


On Wednesday, 18 February 2015 at 20:25:07 UTC, Dicebot wrote:
> Right now I don't care for full memory safety or type safety of 
> any proposed solution. I will be glad to have any that actually 
> works - and I have not heard of any idea that allows to do that 
> without language changes. Your push for owned is also hardly 
> relevant because exceptions are good examples of data with 
> shared / non-determenistic ownership and thus won't benefit 
> from it.

I think it make sense to require that something thrown to be 
owned. That means ownership can be transferred from one thread to 
the other. That also mean that the compiler can free the 
exception when it goes out of scope, which is what is wanted for 
exception and @nogc to work together.

The invalid operation in @nogc would become promoting owned to 
Tl/shared/immutable rather than not allocating at all.

This has added benefit to allow for way more code to be @nogc, 
and in many cases transfers the GCness of something in the 
caller, which makes for @nogc compatible libraries that can be 
used in both @nogc and gc situation.

If we are gonna add something in the language, it'd better be 
worth it.


More information about the Digitalmars-d mailing list