POV-Ray : Newsgroups : povray.text.scene-files : foreach macro : Re: foreach macro Server Time
18 May 2024 22:32:17 EDT (-0400)
  Re: foreach macro  
From: jr
Date: 26 Apr 2021 16:00:00
Message: <web.60871b8cd564bfd479819d986cde94f1@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:
> posting #4 of 'Foreach()'...

tried to see how many levels of nested calls of 'Foreach()' POV-Ray will do,
given that the documentation[*] does not mention a limit.  got to nine.  when I
uncomment the line in 'm_l9', the error shown below code (attached) occurs.
this is the "call stack" getting trashed?

[*]
<https://wiki.povray.org/content/Reference:User_Defined_Macros#The_macro_Directive>


regards, jr.


/* nesting.pov */

#version 3.8;

global_settings {assumed_gamma 1}

#include "foreach.inc"

#declare A = array [4] {1, 2, 3, 4};

#macro m_l10(i_,n_)
  #debug concat("----------> level 10, n = ",str(n_,0,0),".\n")
#end

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

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

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

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

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

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

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

#macro m_l2(i_,n_)
  #debug concat("--> level 2, n = ",str(n_,0,0),".\n")
  Foreach(A, dictionary {.Macro: "m_l3"})
#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"})



Persistence of Vision(tm) Ray Tracer Version 3.8.0-alpha.10064268.unofficial
  ...
==== [Parsing...] ==========================================================
-> level 1, n = 1.
--> level 2, n = 1.
---> level 3, n = 1.
----> level 4, n = 1.
-----> level 5, n = 1.
------> level 6, n = 1.
-------> level 7, n = 1.
--------> level 8, n = 1.
---------> level 9, 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


Post a reply to this message


Attachments:
Download 'nestfail.pov.txt' (2 KB)

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