POV-Ray : Newsgroups : povray.text.scene-files : foreach macro : Re: foreach macro Server Time
15 May 2021 20:43:34 EDT (-0400)
  Re: foreach macro  
From: jr
Date: 27 Apr 2021 06:55:00
Message: <web.6087ec8dd564bfd479819d986cde94f1@news.povray.org>
hi,

William F Pokorny <ano### [at] anonymousorg> wrote:
> On 4/26/21 3:59 PM, jr wrote:
> > tried to see how many levels of nested calls of 'Foreach()' POV-Ray ...
>
> Short on time today, but maybe something with turning and starting back
> up the macro stack? The parse_fore.tmp file looks to contain the last
> m_l10 'execution string'. Is it somehow getting run an extra time on the
> ascent?

thanks for the quick look.  (I don't know the code base)  all foreach calls use
the only array in scene.  no idea where an extra run/invocation [cw]ould come
from.


> If I change m_l8 to call m_l10, I get the same error and it happens
> after all four calls to m_l10 at a depth of 8.

neat.  never even occurred to me.  the 'nesting.pov' "evolved", copy+paste
style, by level, so the "last" macro always was just a '#debug concat', to tie
in with above.

the output below was done with an alpha with three of your patches, plus
clipka's to get it to build.  just .. strange.


> Aside: I don't think any v3.7 version will work to debug this as the
> dictionary feature is new to v3.8.

interestingly, after rigging version and removing the 'global' in line 73 (I
think), the parser does not object to the .inc, in spite of my using 'dict.key'
notation throughout.  may have a play with this Debian build (todo list. :-))


regards, jr.


Script started on Tue 27 Apr 2021 11:23:30 BST

jr@swift:1:foreach$ tail -n15 nesting.pov
#end

#macro m_l2(i_,n_)
  #debug concat("--> level 2, n = ",str(n_,0,0),".\n")
//  Foreach(A, dictionary {.Macro: "m_l3"})
//  Foreach(A, dictionary {.Macro: "m_l10"})
#end

#macro m_l1(i_,n_)
  #debug concat("-> level 1, n = ",str(n_,0,0),".\n")
  Foreach(A, dictionary {.Macro: "m_l2"})
#end

Foreach(A, dictionary {.Macro: "m_l1"})


jr@swift:2:foreach$ povparse nesting.pov
Persistence of Vision(tm) Ray Tracer Version 3.8.0-alpha.10064268.unofficial
  ...
==== [Parsing...] ==========================================================
-> level 1, n = 1.
--> level 2, n = 1.
--> level 2, n = 2.
--> level 2, n = 3.
--> level 2, n = 4.
-> level 1, n = 2.
--> level 2, n = 1.
--> level 2, n = 2.
--> level 2, n = 3.
--> level 2, n = 4.
-> level 1, n = 3.
--> level 2, n = 1.
--> level 2, n = 2.
--> level 2, n = 3.
--> level 2, n = 4.
-> level 1, n = 4.
--> level 2, n = 1.
--> level 2, n = 2.
--> level 2, n = 3.
--> level 2, n = 4.
File 'nesting.pov' line 327: Parse Warning: No objects in scene.


jr@swift:3:foreach$ tail -n15 nesting.pov
#end

#macro m_l2(i_,n_)
  #debug concat("--> level 2, n = ",str(n_,0,0),".\n")
//  Foreach(A, dictionary {.Macro: "m_l3"})
  Foreach(A, dictionary {.Macro: "m_l10"})
#end

#macro m_l1(i_,n_)
  #debug concat("-> level 1, n = ",str(n_,0,0),".\n")
  Foreach(A, dictionary {.Macro: "m_l2"})
#end

Foreach(A, dictionary {.Macro: "m_l1"})


jr@swift:4:foreach$ povparse nesting.pov
  ...
==== [Parsing...] ==========================================================
-> level 1, n = 1.
--> level 2, n = 1.
----------> level 10, n = 1.
----------> level 10, n = 2.
----------> level 10, n = 3.
----------> level 10, n = 4.
File '/tmp/parse_fore.tmp' line 1: Parse Error: Expected 'object or directive',
 ) found instead
Fatal error in parser: Cannot parse input.
Render failed


jr@swift:5:foreach$ tail -n15 nesting.pov
#end

#macro m_l2(i_,n_)
  #debug concat("--> level 2, n = ",str(n_,0,0),".\n")
  Foreach(A, dictionary {.Macro: "m_l3"})
//  Foreach(A, dictionary {.Macro: "m_l10"})
#end

#macro m_l1(i_,n_)
  #debug concat("-> level 1, n = ",str(n_,0,0),".\n")
  Foreach(A, dictionary {.Macro: "m_l2"})
#end

Foreach(A, dictionary {.Macro: "m_l1"})


jr@swift:6:foreach$ povparse nesting.pov
  ...
==== [Parsing...] ==========================================================
-> level 1, n = 1.
--> level 2, n = 1.
---> level 3, n = 1.
---> level 3, n = 2.
  ...
---> level 3, n = 4.
--> level 2, n = 4.
---> level 3, n = 1.
---> level 3, n = 2.
---> level 3, n = 3.
---> level 3, n = 4.
File 'nesting.pov' line 327: Parse Warning: No objects in scene.

(the last with foreach in 'm_l3' commented out)


Post a reply to this message

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