POV-Ray : Newsgroups : povray.beta-test : tuple in dict Server Time
28 Mar 2024 09:34:03 EDT (-0400)
  tuple in dict (Message 1 to 10 of 14)  
Goto Latest 10 Messages Next 4 Messages >>>
From: ingo
Subject: tuple in dict
Date: 25 Nov 2018 11:03:26
Message: <XnsA9A5AD84BC3F1seed7@news.povray.org>
The little test fails on the first line of the second dict with a parse 
error ) expected , found.
If reported before, sorry, havn't followed along for a few years.
If not a bug, please see it as a feature request ;)

#declare fig = dictionary {
  ["head"]  : <0, 0, 0>,
  ["nose"]  : <1, 0, 0>,
  ["atlas"] : <0,-1, 0>,
  ["tail"]  : <0,-3, 0>
}

#declare bone = dictionary {
  ["face"]  : (fig["head"], fig["nose"]),
  ["neck"]  : (fig["head"], fig["atlas"]),
  ["spine"] : (fig["atlas"], fig["tail"])
}

3.8.0-alpha.9893777+av622.msvc14.win64
Win10

ingo


Post a reply to this message

From: ingo
Subject: Re: tuple in dict
Date: 25 Nov 2018 11:13:03
Message: <XnsA9A5AF266B202seed7@news.povray.org>
Probably completely misread the docs on the previous one.

The following parses forever:

#declare fig = dictionary {
  ["head"]  : <0, 0, 0>,
  ["nose"]  : <1, 0, 0>,
  ["atlas"] : <0,-1, 0>,
  ["tail"]  : <0,-3, 0>
}


#declare bone = dictionary {
  ["face"]  : array{fig["head"], fig["nose"]},
  ["neck"]  : array{fig["head"], fig["atlas"]},
  ["spine"] : array{fig["atlas"], fig["tail"]}
}
  
ingo


Post a reply to this message

From: jr
Subject: Re: tuple in dict
Date: 27 Nov 2018 09:15:01
Message: <web.5bfd511f6924cc99783c249c0@news.povray.org>
hi,

ingo <ing### [at] tagpovrayorg> wrote:
> The following parses forever:
>
> #declare fig = dictionary {
>   ["head"]  : <0, 0, 0>,
>   ["nose"]  : <1, 0, 0>,
>   ["atlas"] : <0,-1, 0>,
>   ["tail"]  : <0,-3, 0>
> }
>
>
> #declare bone = dictionary {
>   ["face"]  : array{fig["head"], fig["nose"]},
>   ["neck"]  : array{fig["head"], fig["atlas"]},
>   ["spine"] : array{fig["atlas"], fig["tail"]}
> }
>
> ingo

same for the *nix version.  does not terminate on ^C then, needed 'kill -s hup'.


regards, jr.


Post a reply to this message

From: jr
Subject: Re: tuple in dict
Date: 27 Nov 2018 09:40:00
Message: <web.5bfd56506924cc99783c249c0@news.povray.org>
hi,

ingo <ing### [at] tagpovrayorg> wrote:
> The following parses forever:
>
> #declare fig = dictionary {
>   ["head"]  : <0, 0, 0>,
>   ["nose"]  : <1, 0, 0>,
>   ["atlas"] : <0,-1, 0>,
>   ["tail"]  : <0,-3, 0>
> }
>
>
> #declare bone = dictionary {
>   ["face"]  : array{fig["head"], fig["nose"]},
>   ["neck"]  : array{fig["head"], fig["atlas"]},
>   ["spine"] : array{fig["atlas"], fig["tail"]}
> }
>
> ingo

if you write:

#declare bone = dictionary {
  ["face"]  : array [2] {fig["head"], fig["nose"]},
  ["neck"]  : array [2] {fig["head"], fig["atlas"]},
  ["spine"] : array [2] {fig["atlas"], fig["tail"]}
}

it'll work.


regards, jr.


Post a reply to this message

From: ingo
Subject: Re: tuple in dict
Date: 27 Nov 2018 17:27:27
Message: <XnsA9A7EE9FFD443seed7@news.povray.org>
in news:web.5bfd56506924cc99783c249c0@news.povray.org jr wrote:

> if you write:
> [...]

Thanks. Thats what I started with, but read somewhere the [2] can be 
omitted for one dimensional arrays,

ingo


Post a reply to this message

From: jr
Subject: Re: tuple in dict
Date: 28 Nov 2018 04:15:01
Message: <web.5bfe5bdd6924cc99783c249c0@news.povray.org>
hi,

ingo <ing### [at] tagpovrayorg> wrote:
> in news:web.5bfd56506924cc99783c249c0@news.povray.org jr wrote:
>
> > if you write:
> > [...]
>
> Thanks. Thats what I started with, but read somewhere the [2] can be
> omitted for one dimensional arrays,

yes, a new feature.  I think though that such arrays cannot be initialised where
they're declared  (clipka?).

fwiw, I used such arrays in 'queues.inc', have a look (posted in
text.scene-files, on Nov 6th).


regards, jr.


Post a reply to this message

From: clipka
Subject: Re: tuple in dict
Date: 28 Nov 2018 08:05:21
Message: <5bfe9291$1@news.povray.org>
Am 25.11.2018 um 17:13 schrieb ingo:
> Probably completely misread the docs on the previous one.

Indeed. Tuples are not a thing in POV-Ray. There is only a tuple-ish 
syntax to assign multiple variables at the same time.


> The following parses forever:

That's pretty much the worst of all outcomes. Guess I'll have to look 
into this.


Post a reply to this message

From: clipka
Subject: Re: tuple in dict
Date: 28 Nov 2018 08:06:29
Message: <5bfe92d5@news.povray.org>
Am 27.11.2018 um 15:36 schrieb jr:

> if you write:
> 
> #declare bone = dictionary {
>    ["face"]  : array [2] {fig["head"], fig["nose"]},
>    ["neck"]  : array [2] {fig["head"], fig["atlas"]},
>    ["spine"] : array [2] {fig["atlas"], fig["tail"]}
> }
> 
> it'll work.

Thanks for that find. It'll help narrow down the issue more quickly.


Post a reply to this message

From: clipka
Subject: Re: tuple in dict
Date: 28 Nov 2018 08:18:40
Message: <5bfe95b0$1@news.povray.org>
Am 27.11.2018 um 23:27 schrieb ingo:
> in news:web.5bfd56506924cc99783c249c0@news.povray.org jr wrote:
> 
>> if you write:
>> [...]
> 
> Thanks. Thats what I started with, but read somewhere the [2] can be
> omitted for one dimensional arrays,

Note that this isn't just a matter of convenience - the resulting arrays 
will behave differently, with the "non-sized" array being able to grow 
dynamically. The downside of such dynamically-sized arrays is that they 
require more memory.

So whenever you know the size of the array in advance, omitting it is 
bad practice.


Post a reply to this message

From: clipka
Subject: Re: tuple in dict
Date: 28 Nov 2018 09:26:05
Message: <5bfea57d$1@news.povray.org>
Apparently the dynamically-sized array doesn't like to have an initializer.

So this also enters an infinite loop:

     #declare Foo = array { 42, 4711 };


Post a reply to this message

Goto Latest 10 Messages Next 4 Messages >>>

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