I have made a discovery

w0rp via Digitalmars-d digitalmars-d at puremagic.com
Sun Apr 19 02:57:51 PDT 2015


The interesting thing about this is that 'throw new 
ExceptionType(...)' could be reference counted. The downside of 
not getting rid of the 'new' overloading at some point is that it 
can make the operator do surprising and unexpected things, so the 
rationale for getting rid of it is similar to the rationale 
behind disallowing overloading of '&&' and '||'.

What I found more interesting is that class constructors 
themselves can be marked @nogc, which I never thought to do 
before. So whatever syntax we end up with for 'allocate with this 
other allocator and call this constructor' could take advantage 
of that. I'm not sure how that will end up looking in the end, 
but I am reminded of Objective C again, where allocation and 
construction are explicitly separated.

// Enough time in Wonderland makes this seem perfectly natural.
MyClass* foo = [[MyClass alloc] initWithNumber:3];


More information about the Digitalmars-d mailing list