Proposal 2: Exceptions and @nogc

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sun Apr 9 13:15:46 PDT 2017


On 4/9/2017 1:35 AM, Dukc wrote:
> object aMemoryLeak;
>
> void someFunc()
> {   throw (aMemoryLeak = new Exception("hello world!"));
> }
>
> Would the compiler warn about this or make the exception normally garbage
> collected?

That would be a regular gc allocated Exception.


> I'm not sure, but perhaps an entirely different syntax would be in place for
> throwing a refcounted object, so there's no special casing. For example, could a
> throw statement without the new keyword mean a refcounted throw?

Didn't want to do a new syntax.


More information about the Digitalmars-d mailing list