POV-Ray : Newsgroups : povray.general : Problem with name space for user-defined functions : Re: Problem with name space for user-defined functions Server Time
25 Apr 2024 14:56:10 EDT (-0400)
  Re: Problem with name space for user-defined functions  
From: clipka
Date: 5 Apr 2018 02:11:54
Message: <5ac5be2a$1@news.povray.org>
Am 05.04.2018 um 02:43 schrieb Kenneth:
> I'm understanding most of this-- although I confess that the 'dictionary'
> feature is new to me. I knew it was added to v3.8, but I'm currently clueless as
> to what it's for  :-O

It can be interpreted as an array-ish structure that takes strings as
indices:

    #declare Foo = dictionary;
    #declare Foo["Some Index"] = 4711;

As syntactic sugar, if an index satisfies the rules for an identifier,
the index can also be written using dot notation; for example, the
following two lines are equivalent:

    #declare Foo["Bar"] = 815;
    #declare Foo.Bar = 815;

With this notation in mind, a dictionary can also be interpreted as what
would be called a "struct" in C/C++ or a "record" in Pascal - or as a
namespace, which is pretty much what it actually is under the hood.


The future plan is to also extend dictionaries to be able to hold
macros, which would make them usable for object-oriented programming.
But that still needs a bit of work.


Post a reply to this message

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