Wrong lowering for a[b][c]++
H. S. Teoh
hsteoh at quickfur.ath.cx
Thu Mar 22 07:32:49 PDT 2012
On Thu, Mar 22, 2012 at 11:01:35AM +0100, Andrej Mitrovic wrote:
> On 3/21/12, H. S. Teoh <hsteoh at 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.
T
--
Real Programmers use "cat > a.out".
More information about the Digitalmars-d
mailing list