On Wednesday, May 02, 2012 13:32:04 H. S. Teoh wrote: > 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?
The way that AAs work in this regard is identical to how dynamic arrays work. - Jonathan M Davis