Is this a bug?

David Held via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Apr 29 22:15:35 PDT 2014


On 4/29/2014 10:01 AM, Meta wrote:
> On Tuesday, 29 April 2014 at 16:52:27 UTC, Ali Çehreli wrote:
>> [...]
>> int[] foo()
>> {
>>     int[] a;
>>     a ~= 42;    // on memory owned by the GC
>>     return a;
>> }
>
> I didn't realize this was possible... I figured it was equivalent to
> `null ~= 42` which I realize now is not correct, because a is not
> entirely a reference type. I'm not sure how I feel about this.

Yeah, arrays and AAs sit in a no-man's-land between reference types and 
value types. :(  I don't know that I've seen this precedent in any other 
language...

Dave



More information about the Digitalmars-d-learn mailing list