[dmd-internals] AssociativeArray in druntime should go before the next release

Don Clugston dclugston at googlemail.com
Thu Feb 2 07:46:27 PST 2012


I agree completely. In Bugzilla, I found FIFTEEN reported compiler
regressions caused by the introduction of library AAs. Most were very
difficult to fix; in many cases the fix is very fragile.

Another issue that wasn't on your list: AA literals don't have a
representation outside of the compiler, yet they are a crucial
implementation issue.

Take at look at this code in object.di, it's really incredible:

struct AssociativeArray(Key, Value)
{
   void* p; // really Hashtable*

    Value get(Key key, lazy Value defaultValue)
    {
        auto p = key in *cast(Value[Key]*)(&p);   <------ Think about
what happens here.
        return p ? *p : defaultValue;
    }
}

The CTFE code to cope with this sort of thing is truly awful.

The D2 AA implementation is a pack of cards. If you make a small
change, it will break.
And it's getting worse. So far, every fix has made the compiler more
complicated and more closely tied to the runtime, in very subtle ways.

I think we should cut our losses, and roll it back. This particular
approach is a disaster.


More information about the dmd-internals mailing list