<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 12 January 2014 14:29, Orvid King <span dir="ltr"><<a href="mailto:blah38621@gmail.com" target="_blank">blah38621@gmail.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 Sat, 11 Jan 2014 22:08:25 -0600, Manu <<a href="mailto:turkeyman@gmail.com" target="_blank">turkeyman@gmail.com</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 12 November 2013 18:09, Don <<a href="mailto:x@nospam.com" target="_blank">x@nospam.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
On Monday, 11 November 2013 at 11:39:06 UTC, Daniel Murphy wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
"Manu" <<a href="mailto:turkeyman@gmail.com" target="_blank">turkeyman@gmail.com</a>> wrote in message<br>
<br>
news:mailman.355.1384158631.<u></u>9546.digitalmars-d@puremagic.<u></u>com...<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
immutable string[string] priorityMap = [<br>
<br>
"1" : "blocker",<br>
<br>
"2" : "critical",<br>
<br>
"3" : "critical",<br>
<br>
"4" : "major",<br>
<br>
"5" : "major",<br>
<br>
"6" : "major",<br>
<br>
"7" : "minor",<br>
<br>
"8" : "minor",<br>
<br>
"9" : "trivial" ];<br>
<br>
<br>
<br>
main.d(56): Error: non-constant expression ["1":"blocker", "2":"critical",<br>
<br>
"3":"critical", "4":"major", "5":"major", "6":"major", "7":"minor",<br>
<br>
"8":"minor", "9":"trivial"]<br>
<br>
<br>
<br>
This is tedious, how long has it been now?<br>
<br>
Seriously, static map's are super-important, they should be able to be made<br>
<br>
immutable, and also be able to be initialised.<br>
<br>
<br>
<br>
Maybe this could be factored into the improvements for 2.065?<br>
<br>
<br>
<br>
</blockquote>
<br>
<br>
<br>
I think yes, it can be done for 2.065.  Someone remind me if we get close<br>
<br>
and it isn't done yet.<br>
<br>
</blockquote>
<br>
<br>
<br>
<br>
<br>
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>
<br>
<br>
void foo(int some_param)<br>
<br>
{<br>
<br>
   immutable string[int] = [ 1: "abc", some_param: "def"];<br>
<br>
}<br>
<br>
<br>
<br>
I wish we could get rid of that silliness entirely.<br>
<br>
<br>
<br>
<br>
<br>
If the members are compile-time expressions, you probably want to mark the variable as static >>const/static immutable.<br>
<br>
</blockquote>
<br>
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.<br>

</blockquote>
<br></div></div>
I would disagree with that statement, because it is my understanding of immutable that it merely means that the value is not modified after it is initialized, it does not however mean that the value is determinate at compile-time, nor that it is even the same in all invocations of a function.<br>

</blockquote></div><br></div><div class="gmail_extra">If an immutable is initialised to a literal value, then there is no possible way for variation to exist. It certainly is the same in all invocations of the function, and there's no need to re-allocate+initialise it on every call to the function.</div>
</div>