ref keys

anonymous anonymous at example.com
Mon Sep 17 14:12:26 PDT 2012


On Monday, 17 September 2012 at 13:42:08 UTC, Namespace wrote:
> I can do:
> array[new A()] = 42;
> array[a1] = 23;
>
> Both lines are valid.
> But if I would access the elements later with their keys, I 
> can't because I have not a valid key for the element 42, only 
> for 23.
>
> so my suggestion is: allow ref keys.
>
> int[ref A] array;
> array[new A()] = 42; // <-- error, new A() isn't a lvalue
> array[a1] = 23; // <-- fine

What problem are you trying to solve here? When I forget to keep 
the key around, I'll notice that. I don't need lvalue keys for 
that.



More information about the Digitalmars-d-learn mailing list