|
|
On 9/17/2016 11:45 PM, Mike Horvath wrote:
> On 9/17/2016 11:09 PM, clipka wrote:
>> Am 18.09.2016 um 04:14 schrieb Mike Horvath:
>>> On 9/17/2016 4:41 PM, clipka wrote:
>>>> But I /will/ say more:
>>>>
>>>> #declare MyFrobnitz = dictionary {
>>>> .Foo = 42,
>>>> };
>>>> #declare Key = "Bar";
>>>> #declare MyFrobnitz[Key] = "FTW!";
>>>>
>>>
>>> I don't like the dot before the identifier.
>>
>> On a scale from 0 to 10, how much do you not like it?
>>
>> Also, what alternative would you suggest for the following syntax, and
>> how would you avoid conflicts between the two initializer syntax
>> variants?
>>
>> #declare MyFrobnitz = dictionary {
>> "Foo" = 42,
>> "Bar" = "FTW!"
>> }
>>
>> Bear in mind that it should be possible to replace the string literals
>> with arbitrary string expressions, including simple string identifiers.
>>
>> Also bear in mind that the following syntax variants for individual
>> element access are to be considered (almost) a given:
>>
>> #declare MyFrobnitz.Foo = 42;
>> #declare MyFrobnitz["Foo"] = 42;
>>
>
> I don't understand what you're saying. But Lua (sort of) does it like this:
>
> method 1
>
> #declare MyFrobnitz = dictionary {
> Foo = 42,
> Bar = "FTW!"
> }
>
> method 2
>
> #declare MyFrobnitz = dictionary {
> ["Foo"] = 42,
> ["Bar"] = "FTW!"
> }
>
> method 3
>
> #declare Key1 = "Foo";
> #declare Key2 = "Bar";
> #declare MyFrobnitz = dictionary {
> [Key1] = 42,
> [Key2] = "FTW!"
> }
>
I'm trying to find out if JavaScript does something similar to method 3,
but I don't think it can.
http://www.w3schools.com/js/js_objects.asp
Mike
Post a reply to this message
|
|