<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 12 November 2013 18:09, Don <span dir="ltr"><<a href="mailto:x@nospam.com" target="_blank">x@nospam.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Monday, 11 November 2013 at 11:39:06 UTC, Daniel Murphy wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
"Manu" <<a href="mailto:turkeyman@gmail.com" target="_blank">turkeyman@gmail.com</a>> wrote in message<br>
news:mailman.355.1384158631.<u></u>9546.digitalmars-d@puremagic.<u></u>com...<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
immutable string[string] priorityMap = [<br>
"1" : "blocker",<br>
"2" : "critical",<br>
"3" : "critical",<br>
"4" : "major",<br>
"5" : "major",<br>
"6" : "major",<br>
"7" : "minor",<br>
"8" : "minor",<br>
"9" : "trivial" ];<br>
<br>
main.d(56): Error: non-constant expression ["1":"blocker", "2":"critical",<br>
"3":"critical", "4":"major", "5":"major", "6":"major", "7":"minor",<br>
"8":"minor", "9":"trivial"]<br>
<br>
This is tedious, how long has it been now?<br>
Seriously, static map's are super-important, they should be able to be made<br>
immutable, and also be able to be initialised.<br>
<br>
Maybe this could be factored into the improvements for 2.065?<br>
<br>
</blockquote>
<br>
I think yes, it can be done for 2.065.  Someone remind me if we get close<br>
and it isn't done yet.<br>
</blockquote>
<br>
<br></div></div>
IIRC the poor performance of array literals and AA literals is because they're not always literals, sometimes they are variables (!) and the compiler assumes the worst case. You are allowed to write:<br>
<br>
void foo(int some_param)<br>
{<br>
    immutable string[int] = [ 1: "abc", some_param: "def"];<br>
}<br>
<br>
I wish we could get rid of that silliness entirely.<br>
<br>
<br>
If the members are compile-time expressions, you probably want to mark the variable as static const/static immutable.<br>
</blockquote></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">I've also had this thought. Logically, you shouldn't need to declare an immutable thing static (although currently, you do), although the advantage would be a guaranteed compile error if you try to do something silly like initialise from a variable.</div>
</div>