POV-Ray : Newsgroups : povray.bugreports : array mixed crashes in parser : Re: array mixed crashes in parser Server Time
15 Jul 2024 07:01:37 EDT (-0400)
  Re: array mixed crashes in parser  
From: TreeLimb Jim
Date: 16 Jul 2019 00:35:00
Message: <web.5d2d50f23c87cc69799a5f510@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:
> > //==== THIS GENERATES ERROR ====
> > #declare ColorDictionary = array mixed[2] {
> >  dictionary  { // Upper
> >   ["0"      ]: array[10] { 0,0,0,0,0, 0,0,0,0,0 }
> >   ["1001"]: array[10] { 0,0,0,0,0, 0,0,0,0,0 }
> >   ["1002"]: array[10] { 0,0,0,0,0, 0,0,0,0,0 }
> >   ...

Fixed quite a few things in my code. Best behavior so far:
1. >>>IMPORTANT<<< Dictionary names must be STRING but the initial character
must be an alpha character. This must be documented somewhere already. It makes
it handy to use
the dot delimiter as well as not to confuse elements inside the square brackets
as elements of an array.

2. Declare the array of dictionaries and THEN initialize them as in the
following rewrite:

#declare ColorDictionary = array mixed[2] { dictionary, dictionary }
#declare init10 = array[10] { 0,0,0,0,0, 0,0,0,0,0 }

#macro initColorDictionary()
// Upper
  #declare ColorDictionary[0].m0 = init10
  #declare ColorDictionary[0].m1001 = init10
  #declare ColorDictionary[0].m1002 = init10
// Lower
  #declare ColorDictionary[1].m0 = init10
  #declare ColorDictionary[1].m1001 = init10
  #declare ColorDictionary[1].m1002 = init10
#end

initColorDictionary()


I believe I'm getting closer to coding around a few things about concurrently
declaring and initializing but not simultaneously declare and initializing
arrays, including the superset called mixed arrays.

From preliminary explorations, in mixed arrays, my suggestion during alpha
development is to keep the same data type as initialized for that element and
quite likely, the dimension of the arrays and elements composed of arrays, too.
( brings memories of the horrors of writing context-free grammars and LEX/YACC )


Post a reply to this message

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