One old problem with associative arrays

Don Clugston dac at nospam.com
Wed Nov 7 00:00:14 PST 2012


On 07/11/12 05:38, H. S. Teoh wrote:
> On Wed, Nov 07, 2012 at 05:08:43AM +0100, bearophile wrote:
> [...]
>> So the associative array is updated before taking its length. I
>> suggest to try to fix this AA behavour before too much D2 code relies
>> on this. I'd like to avoid this to become a permanent wart of D2.
>>
>> My bug report is from February 2010, it's in the most important 20
>> bug reports of mine. In my opinion it's wrong to add new features to
>> D before similar bugs are fixed:
>>
>> http://d.puremagic.com/issues/show_bug.cgi?id=3825
> [...]
>
> I'd love to fix AA's once for all. The problem is that right now the AA
> code is scattered all over the compiler, and even within druntime it's a
> schizophrenic mosaic of half-duplicated code, partly in aaA.d and partly
> in object_.d. It's a major undertaking even just to refactor this code
> in a sane way.
>
> Would you like to help in this effort? ;-)
>
> I tried to do it myself some time ago, and I did get as far as a struct
> that works pretty much like the built-in AA's with quite a good number
> of current issues fixed, but it got stuck with handling const, pure,
> IFTI bugs, and a number of related issues.  Frankly, at this point I
> believe that it's going to take more than one person to do it. We need a
> team of about 2-3 to tackle different aspects of it so that we can clean
> up the whole thing properly. My code is already up on github, but so far
> it seems that no one has been interested to contribute yet.
>
> I do agree that cleaning up AA's should be quite an important item in
> D2. There are quite a lot of IMO serious problems with the current
> implementation. But it ain't gonna happen unless more people help.
>
>
> T
>

I keep getting hurt by the bizarre "magic null" that happens with AAs. 
It makes the implementation really horrible.
Can we please please make it so that declaring an AA creates an empty 
AA? So that AAs are always reference types.
(It would also be OK if they had to explicitly created, just like 
classes are; but these semantics of "inserting an item into a null AA 
creates the AA first" is really awful).

Making AAs nicer and less bug-prone for users would make them easier to 
implement!



More information about the Digitalmars-d mailing list