On Tuesday, 2 April 2013 at 04:48:54 UTC, Steven Schveighoffer wrote:
HOWEVER, there is one horrible caveat. You must have assigned an element at least once in order to alias:

Thanks Steve, I had already looked into that, but then got dense and I was treating the AA as having value semantics. I don't need the pointer.

Is there a way to ensure the AA is initialized as not null, besides adding and removing an element? (I couldn't use a literal)

Is the null initializer a consequence of the current opaque implementation, or just of the reference semantics? (I saw on the wiki that there was a desire to use a less opaque implementation. I think the AA ABI should be documented, like the other arrays)

Slightly related, it doesn't seem very reasonable to me that the get method of AAs is not safe:

@safe:

void main()
{
    int[string] x;
    x.get("b", 0);
}

Error: safe function 'D main' cannot call system function 'object.AssociativeArray!(string, int).AssociativeArray.get'

Reply via email to