More magical AA semantics

Jonathan M Davis jmdavisProg at gmx.com
Sat Jan 12 04:04:32 PST 2013


On Saturday, January 12, 2013 11:51:59 monarch_dodra wrote:
> On Saturday, 12 January 2013 at 04:24:01 UTC, deadalnix wrote:
> > On Friday, 11 January 2013 at 13:50:33 UTC, monarch_dodra wrote:
> >> I find that with LTR, you end up with a value (T.init), that
> >> you never actually put into your array. IMO, that means
> >> something went wrong somewhere. This is particularly relevant
> >> with "++a[0]".
> > 
> > Not necessarily, as the computation made for an assignation
> > isn't the one made in order to get the value.
> > 
> > It make sense that such expression fail. As long as the AA as
> > the key are computed before the value and in that order.
> 
> I guess I can see it either way. My only gripe though is that:
> "a[0] = a[0] + 5;"
> 
> Could never work if AA's were a "true" library type. I think this
> is a problem, if the plan is to one day completely move AA's out
> of the compiler.
> 
> That, and for generic programming, it means my user written
> HashMap! will never be able to have AA's semantics.

But that should result in a RangeError. It's not something that's supposed to 
work. It's a bug. So, the fact that a library type couldn't duplicate it is 
irrelevant. The fact that it can't have a particular bug isn't exactly a 
problem.

- Jonathan M Davis


More information about the Digitalmars-d mailing list