ref semantics with hashes
H. S. Teoh
hsteoh at quickfur.ath.cx
Wed May 2 13:32:04 PDT 2012
On Wed, May 02, 2012 at 09:38:35PM +0200, Andrej Mitrovic wrote:
[...]
> So if the hash wasn't already initialized then the reference in the
> Foo struct is a reference to null, and if you duplicate that reference
> and add a key the old reference still points to null.
>
> The only way to ensure a proper link with a hash is to initialize it
> with a key and then immediately remove that key, which makes the hash
> not-null but empty:
[...]
> Why do we have such error-prone semantics?
I was told that this was expected behaviour.
Should the new AA implementation change this, so that it always
allocates an empty AA upon instantiation?
T
--
For every argument for something, there is always an equal and opposite argument against it. Debates don't give answers, only wounded or inflated egos.
More information about the Digitalmars-d-learn
mailing list