Why doesn't this have a length?

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Mar 13 07:24:37 PDT 2012


On Tue, Mar 13, 2012 at 10:02:02AM +0100, Magnus Lie Hetland wrote:
> On 2012-03-13 02:27:46 +0000, Simen Kjærås said:
> 
> >Weird.
> 
> Indeed. Would've thought const AA keys would be reasonable. (In
> Python they're *required*... :)
[...]

I'm of the opinion that AA keys should be *implicitly* immutable. It
makes no sense to have mutable AA keys:

	int[] mykey = [1,2,3,4];
	string[int[]] aa;
	aa[mykey] = "abc";
	mykey[0] = 2;	// monkey business: mykey has changed but aa
			// doesn't know about it
	assert(([1,2,3,4] in aa) !is null); // this will fail

But requiring the user to constantly type overly-long type specs like
string[immutable int[]] just makes AA's annoying to use, especially if
unqualified key types are always illegal.


T

-- 
Your inconsistency is the only consistent thing about you! -- KD


More information about the Digitalmars-d-learn mailing list