POV-Ray : Newsgroups : povray.beta-test : I have a hunch some of you may like this... : Re: I have a hunch some of you may like this... Server Time
19 Apr 2024 23:39:06 EDT (-0400)
  Re: I have a hunch some of you may like this...  
From: clipka
Date: 17 Sep 2016 16:21:13
Message: <57dda5b9$1@news.povray.org>
Am 17.09.2016 um 20:18 schrieb Mike Horvath:

>> Future plans:
>>
>> - Support for an array-like syntax, e.g. `MyFrobnitz["Foo"]` (originally
>> intended to be the primary syntax, with the dot notation planned as a
>> later syntactic sugar extension, but the parser's internals got in my
>> way, so I decided to go for the easier part first)
>>
>> - Support for initializers (if you have any suggestions for the syntax
>> to be used, please let me know)
>>
> 
> Will there be a shorthand syntax too? Like:
> 
> MyFrobnitz =
> {
>     Foo = 42,
>     Bar = "FTW!"
> }

See the "Support for initializers" future plan.

Currently, I intend to implement the following syntax:

    #declare MyFrobnitz = dictionary {
      .Foo = 42,
      .Bar = "FTW!"
    }

I've come to the conclusion that the leading dots should be mandatory
(at least for now), to avoid potential ambiguities in case a
string-based initialization is also implemented, which /may/ ultimately
be specified to allow the following:

    #declare MyFrobnitz = dictionary {
      "Foo" = 42,
      "Bar" = "FTW!"
    }

Since this would probably not be limited to string literals, but would
allow for arbitary string expressions, this would also allow for:

    #declare FooKey = "Foo";
    #declare BarKey = "Bar";
    #declare MyFrobnitz = dictionary {
      FooKey = 42,
      BarKey = "FTW!"
    }

That would obviously be ambiguous if the identifier-based initializer
syntax wouldn't use leading dots.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.