AA's and mutating keys

Jarrett Billingsley kb3ctd2 at yahoo.com
Wed Oct 31 08:23:44 PDT 2007


"Steven Schveighoffer" <schveiguy at yahoo.com> wrote in message 
news:fga4ah$kov$1 at digitalmars.com...
> There isn't any documentation that I can tell on the Arrays page that 
> determines whether a mutating key can be used for an AA.  For example, if 
> I use char[] as a key:
>
> char[][char[]] map;
>
> char[] keyvalue = "hello";
>
> map[keyvalue] = "world";
> keyvalue[] = "cello";
>
> char[] *val = "hello" in map;
>
> So does val get set to non-null?
>
> -Steve

Never ever ever ever ever ever ever do this.  Really.  I'm pretty sure what 
you get from that 'in' is undefined.

Some languages go so far as to disallow using mutable types as map keys 
(i.e. Python).  It's just bad news. 




More information about the Digitalmars-d-learn mailing list