Question about @nogc in D 2.066

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 11 13:28:29 PDT 2014


On Friday, 11 July 2014 at 20:02:32 UTC, Weasel wrote:
> Why does the s1 not throw an error, but the a1 does?

Strings don't allocate upon use whereas all other arrays do 
unless you specifically mark it as static - immutability isn't 
considered here (I think because the part of the compiler that 
looks at the array literal doesn't look at the type on the left 
hand side so it just doesn't know but i'm not sure about why).

But if you make the immutable other array static it shouldn't GC 
allocate.


More information about the Digitalmars-d-learn mailing list