Re: AA char[] as key

2012-01-03 Thread bearophile
simendsjo: Shouldn't T[char[]] be disallowed, and have to be written as T[immutable(char)[]] instead of a silent rewrite? Of course. I have a Bugzilla issue on this. Bye, bearophile

Re: AA char[] as key

2012-01-03 Thread Andrew Wiley
[immutable(char)[]] instead of a silent rewrite?    alias long[char[]] AA;    // key automatically changed to const(char)[]    static assert(is(AA == long[const(char)[]]));    AA aa;    aa[a] = 10;    // error - have to use immutable keys    aa[b.dup] = 11; By design, the problem is things like

Re: AA char[] as key

2012-01-03 Thread Andrew Wiley
..?) Shouldn't T[char[]] be disallowed, and have to be written as T[immutable(char)[]] instead of a silent rewrite?    alias long[char[]] AA;    // key automatically changed to const(char)[]    static assert(is(AA == long[const(char)[]]));    AA aa;    aa[a] = 10;    // error - have

Re: AA char[] as key

2012-01-03 Thread simendsjo
[]] be disallowed, and have to be written as T[immutable(char)[]] instead of a silent rewrite? alias long[char[]] AA; // key automatically changed to const(char)[] static assert(is(AA == long[const(char)[]])); AA aa; aa[a] = 10; // error - have to use immutable keys aa[b.dup] = 11

Re: AA char[] as key

2012-01-03 Thread Andrew Wiley
automatically convert to const (right...?) Shouldn't T[char[]] be disallowed, and have to be written as T[immutable(char)[]] instead of a silent rewrite?    alias long[char[]] AA;    // key automatically changed to const(char)[]    static assert(is(AA == long[const(char)[]]));    AA aa

Re: AA char[] as key

2012-01-03 Thread bearophile
Andrew Wiley: If the compiler is basically going to disallow using the AA as anything but a long[string], it should really disallow declaring anything with a mutable key type. Disallowing mutable keys at that assignment site but allowing them in the type is confusing. Two related bug

Re: AA char[] as key

2012-01-03 Thread Andrew Wiley
On Tue, Jan 3, 2012 at 4:20 PM, bearophile bearophileh...@lycos.com wrote: Andrew Wiley: If the compiler is basically going to disallow using the AA as anything but a long[string], it should really disallow declaring anything with a mutable key type. Disallowing mutable keys at that

Re: AA char[] as key

2012-01-03 Thread bearophile
Andrew Wiley: Some consequences of actually changing this: - This breaks D1 compatibility of AAs across the board because immutable simply didn't exist then D1 compatibility will stop being a problem in some time :-) - Significant D2 code breakage as well It's essentially wrong code,