Robustness of the built in associative array
Oskar Linde
oskar.lindeREM at OVEgmail.com
Fri Mar 24 09:17:41 PST 2006
Nick wrote:
> In article <e00v0m$te2$3 at digitaldaemon.com>, Oskar Linde says...
>> Hello,
>>
>> The latest "Implicit fn template instantiation" thread contains code
>> that contains a hidden and possibly hard to find bug.
>> [...]
>
> Good catch!
>
>> 2) Why even keep the builtin AA? With the addition of an opIn()
>> overload, you could get *exactly* the same functionality from a library
>> implementation
>
> Nope, in fact, you couldn't. The kicker is that the builtin AA uses some syntax
> that is currently _impossible_ to duplicate in custom types. Eg. the following:
>
> # int[int] ii;
> # ii[10]++;
You correct. I don't know how I could have forgotten that. D's lack of a
reference return type has implications on properties too.
> I find it rather confusing and frustrating. In my current project I ended up
> making my own template AA to get around some of the deficiencies of the builtin
> type. Mostly I wanted to avoid double lookups, and easily allow custom hashers
> without encapsulating the key in a struct/class (think case-insensitive char[]
> keys.) The result was also faster and more memory efficient than the builtin AA.
I have similar experiences implementing a custom templated hash-table.
/Oskar
More information about the Digitalmars-d
mailing list