QtD is suspended
Bruno Medeiros
brunodomedeiros+spam at com.gmail
Fri Oct 8 04:00:57 PDT 2010
On 17/09/2010 17:44, Andrei Alexandrescu wrote:
> On 9/17/10 10:48 CDT, Michel Fortin wrote:
>> In my mind it's simpler to just explain the notion that an uninitialized
>> hash is null and detached from anything else until initialized. Objects
>> works like this (minus the implicit initialization part), so it
>> shouldn't be too hard to understand. Better have pragmatic semantics
>> that work rather than idealistic semantics that fail at a number of
>> cases.
>
> That's a fair point.
>
>
> Andrei
And perhaps even better would be to have the
associative-arrays/hash-maps behave just like an object (and dynamic
arrays), instead of being a covert pseudo-reference type that gets
implicitly initialized. It is a more natural and consistent behavior.
The only claimed drawback is performance, but I'm having a hard time
understanding what use case motivates this: why do we want lazy
initialized hashmaps anyways? You only get a performance benefit in the
cases where you end up using the hashmap but not require it to be
initialized, and these cases seems fairly rare. I don't think they
justify the current behavior. Can someone give me a code sample or
scenario where hashmap lazy initialization would be better than the more
orthogonal object-like approach I mentioned above?
--
Bruno Medeiros - Software Engineer
More information about the Digitalmars-d-announce
mailing list