Const module globals and static this()

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Feb 15 10:29:56 PST 2012


Why doesn't this compile?

	const int map[dstring];
	static this() {
		map["abc"] = 123;
	}

It seems utterly pointless to be able to declare a const associative
array yet be unable to initialize it (trying to initialize it with an AA
literal doesn't work, the compiler complains the literal is
non-constant).

AA's are a very welcome inclusion in D (IMNSHO, no modern programming
language worth its salt should omit AA's), but they do have some aspects
that are utterly annoying.


T

-- 
Food and laptops don't mix.


More information about the Digitalmars-d-learn mailing list