ref keys
Jonathan M Davis
jmdavisProg at gmx.com
Mon Sep 17 13:33:03 PDT 2012
On Monday, September 17, 2012 20:56:21 Namespace wrote:
> As you can see here, you can change the key very easily:
> http://dpaste.dzfl.pl/71697a23
It's a bug. It should already be reported somewhere, but I can't find it, so
re-reported it:
http://d.puremagic.com/issues/show_bug.cgi?id=8681
The compiler properly checks for immutability with arrays but fails to with
objects for some reason.
> But even they would be immutable: I have still no guarantee that
> my key must be a lvalue. Or am I wrong? Otherwise I'm still for
> ref keys.
Why would the key need to be an lvalue? You're _never_ supposed to assign to
it or alter it in any way. If you do that (which the compiler is supposed to
prevent), then that screws up the hashing. If you changed the value of a key,
then when you went to fetch the element associated with it, you wouldn't find
it, because the hash had changed.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list