Proposal 2: Exceptions and @nogc

Andrew Godfrey via Digitalmars-d digitalmars-d at puremagic.com
Sun Apr 9 18:32:06 PDT 2017


On Monday, 10 April 2017 at 00:48:39 UTC, Walter Bright wrote:
> On 4/9/2017 5:12 PM, Andrew Godfrey wrote:
>> Is it general?
>
> No.
>
>> If not, what is special about Exceptions that makes it work 
>> here?
>
> It only works because all ways that such exceptions can leak 
> are controlled. D doesn't have copy construction for making 
> copies of class references. You couldn't use this scheme, for 
> example, to stuff class references into struct fields.

Ok. So then if I have created a refcounted Exception, and later 
(in another function) I take a reference to it (by stuffing it 
into a struct field, say), how does that work? What is the value 
of _refcount after that happens? Is it 0? Or do we take "one more 
reference to indicate the GC owns it"?


More information about the Digitalmars-d mailing list