On 3/22/12 9:32 AM, H. S. Teoh wrote:
On Thu, Mar 22, 2012 at 11:01:35AM +0100, Andrej Mitrovic wrote:
On 3/21/12, H. S. Teoh<hst...@quickfur.ath.cx>  wrote:
Sorry, I was thinking in terms of my AA implementation which is done
using a struct with operator overloading. I should've checked what the
behaviour of the current built-in AAs are before posting. :-P

Well in that case isn't it a necessity to keep compatibility with the
old implementation? Do we really have to break user-code again?

Yes we have to keep compatibility. But as some have pointed out, this
works:

        int[string][int] map;
        map[20]["abc"]++;     // sets map[20]["abc"] to 1

Looking at druntime code, I see that in aaA.d there's _aaGetX (which
creates a new entry if it doesn't already exist) and _aaGetRvalueX
(doesn't create new entry).  Which look like the equivalents of
opIndexCreate and opIndex.

The problem is that the language doesn't currently support the former in
user-defined structs; so this *will* break compatibility.

This is a bug in the language that requires fixing.

Andrei


Reply via email to