Thread overview | |||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
November 11, 2013 AA literals/initialisation | ||||
---|---|---|---|---|
| ||||
Attachments:
| 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? |
November 11, 2013 Re: AA literals/initialisation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | 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?
The workaround is simple at global scope, but I agree it clutters the code:
immutable string[string] priorityMap;
shared static this() {
priorityMap = [
"1" : "blocker",
"2" : "critical",
"3" : "critical",
"4" : "major",
"5" : "major",
"6" : "major",
"7" : "minor",
"8" : "minor",
"9" : "trivial" ];
}
|
November 11, 2013 Re: AA literals/initialisation | ||||
---|---|---|---|---|
| ||||
Posted in reply to simendsjo Attachments:
| A work-around of that type required by a core language feature is not a sign of quality...
It get's me every single time, and I forget and have to go and find out why
again each time.
Please, fix it finally.
On 11 November 2013 18:33, simendsjo <simendsjo@gmail.com> 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?
>>
>
> The workaround is simple at global scope, but I agree it clutters the code:
>
> immutable string[string] priorityMap;
> shared static this() {
>
> priorityMap = [
> "1" : "blocker",
> "2" : "critical",
> "3" : "critical",
> "4" : "major",
> "5" : "major",
> "6" : "major",
> "7" : "minor",
> "8" : "minor",
> "9" : "trivial" ];
> }
>
|
November 11, 2013 Re: AA literals/initialisation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | 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?
this work ok for me:
immutable priorityMap = [
"1" : "blocker",
"2" : "critical",
"3" : "critical",
"4" : "major",
"5" : "major",
"6" : "major",
"7" : "minor",
"8" : "minor",
"9" : "trivial" ];
|
November 11, 2013 Re: AA literals/initialisation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | 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" ];
|
November 11, 2013 Re: AA literals/initialisation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Kozak | 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
|
November 11, 2013 Re: AA literals/initialisation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Kozak | 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" ];
|
November 11, 2013 Re: AA literals/initialisation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Kozak Attachments:
| On 11 November 2013 20:14, Daniel Kozak <kozzi11@gmail.com> wrote:
> 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" ];
>
So it does... I didn't think of an enum AA ;)
|
November 11, 2013 Re: AA literals/initialisation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | "Manu" <turkeyman@gmail.com> wrote in message news:mailman.355.1384158631.9546.digitalmars-d@puremagic.com... > 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? > I think yes, it can be done for 2.065. Someone remind me if we get close and it isn't done yet. |
November 11, 2013 Re: AA literals/initialisation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | 11-Nov-2013 15:06, Manu пишет: > but enum works fine: > > enum priorityMap = [ > > "1" : "blocker", > "2" : "critical", > "3" : "critical", > "4" : "major", > "5" : "major", > "6" : "major", > "7" : "minor", > "8" : "minor", > "9" : "trivial" ]; > > > So it does... I didn't think of an enum AA ;) ... copy pastes that literal everywhere, I'm sure you'll like it ;) -- Dmitry Olshansky |
Copyright © 1999-2021 by the D Language Foundation