AA literals/initialisation

Daniel Kozak kozzi11 at gmail.com
Mon Nov 11 02:14:15 PST 2013


On Monday, 11 November 2013 at 10:13:02 UTC, Daniel Kozak wrote:
> On Monday, 11 November 2013 at 10:11:18 UTC, Daniel Kozak wrote:
>> On Monday, 11 November 2013 at 08:30:32 UTC, Manu wrote:
>>> immutable string[string] priorityMap = [
>>> "1" : "blocker",
>>> "2" : "critical",
>>> "3" : "critical",
>>> "4" : "major",
>>> "5" : "major",
>>> "6" : "major",
>>> "7" : "minor",
>>> "8" : "minor",
>>> "9" : "trivial" ];
>>>
>>> main.d(56): Error: non-constant expression ["1":"blocker", 
>>> "2":"critical",
>>> "3":"critical", "4":"major", "5":"major", "6":"major", 
>>> "7":"minor",
>>> "8":"minor", "9":"trivial"]
>>>
>>> This is tedious, how long has it been now?
>>> Seriously, static map's are super-important, they should be 
>>> able to be made
>>> immutable, and also be able to be initialised.
>>>
>>> Maybe this could be factored into the improvements for 2.065?
>>
>> And even this works ok:
>>
>> immutable string[string] priorityMap = [
>> "1" : "blocker",
>> "2" : "critical",
>> "3" : "critical",
>> "4" : "major",
>> "5" : "major",
>> "6" : "major",
>> "7" : "minor",
>> "8" : "minor",
>> "9" : "trivial" ];
>
> Ohh, but non works on module scope, so yes, it would be fine to 
> fix this

but enum works fine:

enum priorityMap = [
     "1" : "blocker",
     "2" : "critical",
     "3" : "critical",
     "4" : "major",
     "5" : "major",
     "6" : "major",
     "7" : "minor",
     "8" : "minor",
     "9" : "trivial" ];


More information about the Digitalmars-d mailing list