Bad AA behavior
Kirk McDonald
kirklin.mcdonald at gmail.com
Sun Dec 24 13:18:44 PST 2006
BCS wrote:
> Good point. But what about this
>
> void main()
> {
> byte[char[]] set;
> char[] it = "it".dup;
> set[it] = 0;
> assert("it" in set); // pass
> it[0] = 'a';
> it[1] = 'a';
> assert(set.keys[0] in set); // fail
> }
>
> Furthermore, once the underling data is changed, the member can't be
> accessed even to remove it.
>
> set.remove(set.keys[0]); // has no effect
>
> I'll admit that I don't known what to do with the object/struct case,
> but I think the current behavior isn't good.
And this is why dictionary keys are required to be immutable in Python
(and numbers, strings, and tuples are all immutable types).
--
Kirk McDonald
Pyd: Wrapping Python with D
http://pyd.dsource.org
More information about the Digitalmars-d-bugs
mailing list