POV-Ray : Newsgroups : povray.documentation.inbuilt : dictionary container types Server Time: 18 Jan 2019 02:05:13 GMT
  dictionary container types (Message 1 to 10 of 19)  
Goto Latest 10 Messages Next 9 Messages >>>
From: Jim Holsenback
Subject: dictionary container types
Date: 19 Nov 2016 15:38:36
Message: <583071fc$1@news.povray.org>
from discussion Classes/containers in sdl? in p.advanced-users i know 
for a fact that this hasn't been added to docs either ... it was 
mentioned that the syntax is still in flux. i just wanted to post here 
as a reminder to follow up. @Bill ... would you mind following up with a 
link so i can have a look at what we have so far and /maybe/ get started 
on that ... thanks in advance


Post a reply to this message

From: clipka
Subject: Re: dictionary container types
Date: 19 Nov 2016 19:26:53
Message: <5830a77d$1@news.povray.org>
Am 19.11.2016 um 16:38 schrieb Jim Holsenback:
> from discussion Classes/containers in sdl? in p.advanced-users i know
> for a fact that this hasn't been added to docs either ... it was
> mentioned that the syntax is still in flux. i just wanted to post here
> as a reminder to follow up. @Bill ... would you mind following up with a
> link so i can have a look at what we have so far and /maybe/ get started
> on that ... thanks in advance

It's not in the main branch yet, so should probably not be added to the
docs yet; however, for the records:

Arrays will be modified as follows:

- Array elements will no longer have to be all of the same type.
- Caveat: Mixing elements of different type will increase memory
consumption; the increased memory footprint will not revert even if the
array is later set to elements all of the same type.

- An array can be declared without specifying any dimensions; in this
case the array will be one-dimensional and be able to grow in size
dynamically.
- Accessing an element beyond the nominal size of such an array will
automatically increase the nominal size just enough to include that element.
- Caveat: The memory footprint may be twice as high as required for the
current nominal size.
- Caveat: Growth of such an array is triggered by /any/ access to an
element beyond the nominal size; this includes tests such as
`#ifdef(ARRAY[INDEX])`.

Also, so-called "dictionaries" will be added, i.e. containers that map
string keys to arbitrary-type values; if the syntax remains as currently
implemented, it will be as follows:

    // create an empty dictionary
    #declare Fnord = dictionary;

    // create a dictionary with elements
    #declare Fnord = dictionary {
      ["Foo"]: 42,
      ["Bar"]: sphere { <0,0,0>, 1 }
    }

    // alternative
    #declare Fnord = dictionary {
      .Foo: 42,
      .Bar: sphere { <0,0,0>, 1 }
    }

    // access a dictionary element
    #declare Fnord["Foo"] = 42;
    #declare Answer = Fnord["Foo"];

    // alternative
    #declare Fnord.Foo = 42;
    #declare Answer = Fnord.Foo;

    // testing whether a dictionary contains a particular key
    // (e.g.)
    #ifdef (Fnord.["Foo"]) ... #end
    #declare FooKeyExists = defined(Fnord.Foo);

    // removing a key from a dictionary
    // (e.g.)
    #undef Fnord["Foo"];

When using square bracket notation, the keys do not necessarily have to
be string literals, but can be arbitrary string expressions.

When using dot notation, the indices must follow the generic rules for
identifiers.


Post a reply to this message

From: clipka
Subject: Re: dictionary container types
Date: 19 Nov 2016 23:18:55
Message: <5830dddf$1@news.povray.org>
Am 19.11.2016 um 20:26 schrieb clipka:

> It's not in the main branch yet, so should probably not be added to the
> docs yet; however, for the records:

BTW, the syntax can be test-driven with this version:

https://github.com/POV-Ray/povray/releases/tag/v3.7.1-x.dictionary.8877243


Post a reply to this message

From: Mike Horvath
Subject: Re: dictionary container types
Date: 20 Nov 2016 00:10:11
Message: <5830e9e3$1@news.povray.org>
On 11/19/2016 2:26 PM, clipka wrote:
>     // alternative
>     #declare Fnord = dictionary {
>       .Foo: 42,
>       .Bar: sphere { <0,0,0>, 1 }
>     }

Will the dotted syntax allow people to use strings like ".declare" or 
".texture"? I don't think it should.

Mike


Post a reply to this message

From: clipka
Subject: Re: dictionary container types
Date: 20 Nov 2016 00:34:31
Message: <5830ef97$1@news.povray.org>
Am 20.11.2016 um 01:10 schrieb Mike Horvath:
> On 11/19/2016 2:26 PM, clipka wrote:
>>     // alternative
>>     #declare Fnord = dictionary {
>>       .Foo: 42,
>>       .Bar: sphere { <0,0,0>, 1 }
>>     }
> 
> Will the dotted syntax allow people to use strings like ".declare" or
> ".texture"? I don't think it should.

No -- just like with variable identifiers, keywords are not allowed there.


Post a reply to this message

From: clipka
Subject: Re: dictionary container types
Date: 22 Nov 2016 07:31:45
Message: <5833f461$1@news.povray.org>
Am 19.11.2016 um 20:26 schrieb clipka:

>     // testing whether a dictionary contains a particular key
>     // (e.g.)
>     #ifdef (Fnord.["Foo"]) ... #end
>     #declare FooKeyExists = defined(Fnord.Foo);

Of course that should be

    #ifdef (Fnord["Foo"]) ... #end


Post a reply to this message

From: Mike Horvath
Subject: Re: dictionary container types
Date: 22 Nov 2016 07:35:40
Message: <5833f54c$1@news.povray.org>
On 11/19/2016 7:34 PM, clipka wrote:
> Am 20.11.2016 um 01:10 schrieb Mike Horvath:
>> On 11/19/2016 2:26 PM, clipka wrote:
>>>     // alternative
>>>     #declare Fnord = dictionary {
>>>       .Foo: 42,
>>>       .Bar: sphere { <0,0,0>, 1 }
>>>     }
>>
>> Will the dotted syntax allow people to use strings like ".declare" or
>> ".texture"? I don't think it should.
>
> No -- just like with variable identifiers, keywords are not allowed there.
>

I still think the dot is superfluous.


Mike


Post a reply to this message

From: Jim Holsenback
Subject: Re: dictionary container types
Date: 22 Nov 2016 22:25:11
Message: <5834c5c7$1@news.povray.org>
On 11/19/2016 2:26 PM, clipka wrote:
> for the records:

thanks for that ... i went ahead and created a talk page: 
http://wiki.povray.org/content/Reference_Talk:Array

i still need to work the new keyword into the syntax diagram and do an 
overall review of the rest of the page ... go ahead and work over there 
if you want to make any changes


Post a reply to this message

From: Jim Holsenback
Subject: Re: dictionary container types
Date: 23 Nov 2016 12:11:32
Message: <58358774$1@news.povray.org>
On 11/22/2016 5:25 PM, Jim Holsenback wrote:
> On 11/19/2016 2:26 PM, clipka wrote:
>> for the records:
>
> thanks for that ... i went ahead and created a talk page:
> http://wiki.povray.org/content/Reference_Talk:Array
>
> i still need to work the new keyword into the syntax diagram and do an
> overall review of the rest of the page ... go ahead and work over there
> if you want to make any changes

finished page clean up and made a stab at the syntax diagram ... please 
review that to make sure that i haven't forgotten or mis-characterized 
anything


Post a reply to this message

From: clipka
Subject: Re: dictionary container types
Date: 23 Nov 2016 15:04:44
Message: <5835b00c$1@news.povray.org>
Am 23.11.2016 um 13:11 schrieb Jim Holsenback:
> On 11/22/2016 5:25 PM, Jim Holsenback wrote:
>> On 11/19/2016 2:26 PM, clipka wrote:
>>> for the records:
>>
>> thanks for that ... i went ahead and created a talk page:
>> http://wiki.povray.org/content/Reference_Talk:Array
>>
>> i still need to work the new keyword into the syntax diagram and do an
>> overall review of the rest of the page ... go ahead and work over there
>> if you want to make any changes
> 
> finished page clean up and made a stab at the syntax diagram ... please
> review that to make sure that i haven't forgotten or mis-characterized
> anything

Array:

"[...] IDENTIFIER is the name of the identifier up to 40 characters long
[...]"

That's outdated; there is no hard-coded limit for the length of
identifiers anymore.

"Large uninitialized arrays do not take much memory. Internally they are
arrays of pointers so they probably use just 4 bytes per element"

We should probably update that to "8 bytes per element", to account for
the rise of 64-bit machines.


Dictionary:

The DICTIONARY_DECLARATION syntax implies that a DICTIONARY_INITIALIZER
can only be specified with #declare, not with #local. That is not true:
Both #declare and #local allow for a DICTIONARY_INITIALIZER.

The DICTIONARY_ITEM syntax implies that it can be a
DICTIONARY_INITIALIZER; this is also wrong. The corresponding portion of
the array syntax accounts for the nested initializers of
multi-dimensional arrays, but dictionaries always have just one dimension.

The DICTIONARY_ENTRY syntax implies that it can only be an int, float or
string. This is not the case: Anything you can shove into an array can
also be shoved into a dictionary.

The changes to array syntax and behaviour don't fit into the
"Dictionary" section; they should instead be in the "Array" section.


Post a reply to this message

Goto Latest 10 Messages Next 9 Messages >>>

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