Behaviour of AAs after initialization

Puming via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 7 20:14:40 PDT 2014


On Thursday, 7 August 2014 at 17:42:29 UTC, Marc Schütz wrote:
> On Thursday, 7 August 2014 at 17:35:46 UTC, Puming wrote:
>> So I'd like to suggest a rule here similar to what assignment 
>> does to null AA:
>>
>> If someone refers to an uninitialized null AA ( in 
>> implementation, that maybe, a copy of a null AA struct 
>> happens), allocate it first.
>
> I'm afraid that copying is too general. This would trigger on 
> just about any access.

I don't know the details, I was thinking that copy only happens 
when an assignment (`auto aa2 = aa1;`) happens :-(

> It would also make copying AAs more expensive.

all writes to AA already do the same check, right? but if you 
mean all reads will also incur copying, then I agree it would be 
more expensive.

> I believe a standardized method for initializing an AA is more 
> likely to be accepted.



More information about the Digitalmars-d mailing list