POV-Ray : Newsgroups : povray.text.scene-files : foreach macro Server Time
5 May 2024 16:46:17 EDT (-0400)
  foreach macro (Message 9 to 18 of 30)  
<<< Previous 8 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: ingo
Subject: Re: foreach macro
Date: 16 Apr 2021 17:05:51
Message: <XnsAD0EEAF4F3831seed7@news.povray.org>
in news:web.6079f615d564bfd479819d986cde94f1@news.povray.org jr wrote:

></sigh>

Ah, the sound of enthousiasm :)

Ingo


Post a reply to this message

From: jr
Subject: Re: foreach macro
Date: 16 Apr 2021 17:50:00
Message: <web.607a05bad564bfd479819d986cde94f1@news.povray.org>
hi,

ingo <ing### [at] tagpovrayorg> wrote:
> in news:web.6079f615d564bfd479819d986cde94f1@news.povray.org jr wrote:
>
> ></sigh>
>
> Ah, the sound of enthousiasm :)

</grin>  thanks.

btw, as Robert writes, the mp3 plays fine.  checked with 'mpg123' on another
machine.


regards, jr.


Post a reply to this message

From: jr
Subject: Re: foreach macro
Date: 20 Apr 2021 04:40:00
Message: <web.607e933fd564bfd479819d986cde94f1@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:
> "jr" <cre### [at] gmailcom> wrote:
> > and now a snapshot of #3.  ...
> another snapshot of #3.  ...

posting the last snapshot/wip version #3.  both the .inc and demo scene files
are now in their final form, more or less.  the .html page needs a little more
work; an example or two to add, and improving the writing.  to that end I'd be
grateful for people highlighting errors, and suggesting better English where
needed[*].


enjoy, jr.

[*] though I won't capitalise the first word in each sentence.  :-)


Post a reply to this message


Attachments:
Download 'foreach3b.zip' (11 KB)

From: William F Pokorny
Subject: Re: foreach macro
Date: 20 Apr 2021 09:03:57
Message: <607ed13d$1@news.povray.org>
On 4/20/21 4:39 AM, jr wrote:
> "jr" <cre### [at] gmailcom> wrote:
>> "jr" <cre### [at] gmailcom> wrote:
>>> and now a snapshot of #3.  ...
>> another snapshot of #3.  ...
> 
> posting the last snapshot/wip version #3.  both the .inc and demo scene files
> are now in their final form, more or less.  the .html page needs a little more
> work; an example or two to add, and improving the writing.  to that end I'd be
> grateful for people highlighting errors, and suggesting better English where
> needed[*].
...
> 

Quickly on the html.


---
...to avoid potential name clashes, own key names should be captialised...

should be:

...to avoid potential name clashes, your own key names should be 
captialised...


---
A vote to avoid the 'otoh' acronym and write out the words.


---
the '.Walk' examples showed...

Perhaps better as:

the '.Walk' examples show...


---
At the very bottom of the html I see the word 'bool' ?


Bill P.


Post a reply to this message

From: jr
Subject: Re: foreach macro
Date: 20 Apr 2021 09:35:00
Message: <web.607ed789d564bfd479819d986cde94f1@news.povray.org>
hi,

William F Pokorny <ano### [at] anonymousorg> wrote:
> On 4/20/21 4:39 AM, jr wrote:
> ...
>
> Quickly on the html.

(thanks)


> ---
> ...to avoid potential name clashes, own key names should be captialised...
>
> should be:
>
> ...to avoid potential name clashes, your own key names should be
> captialised...
>
>
> ---
> A vote to avoid the 'otoh' acronym and write out the words.

agree, both.


> ---
> the '.Walk' examples showed...
>
> Perhaps better as:
>
> the '.Walk' examples show...

I used past tense because the examples come before and the assumption was/is
that they'd just been read/perused.  will have a closer look/re-assessment.


> ---
> At the very bottom of the html I see the word 'bool' ?

that one's "harmless", I have no examples yet for 'void vs bool', only in the
demo scene.  :-)


regards, jr.


Post a reply to this message

From: jr
Subject: Re: foreach macro
Date: 22 Apr 2021 15:50:00
Message: <web.6081d2afd564bfd479819d986cde94f1@news.povray.org>
hi,

posting #4 of 'Foreach()', probably final.  the attached zip contains the
include file, a demo scene, and (html) documentation with hopefully no further
errors[*].  I wanted to add another demo/"teaser" scene but run out of time, in
the coming days perhaps.


enjoy, jr.

[*] WFP's correction of "showed" led me to find, and get rid of, another
confusing (egregious :-)) copy+paste error.


Post a reply to this message


Attachments:
Download 'foreach4.zip' (12 KB)

From: jr
Subject: Re: foreach macro
Date: 24 Apr 2021 11:00:00
Message: <web.6084314cd564bfd479819d986cde94f1@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:
> ...  I wanted to add another demo/"teaser" scene but run out of time, in
> the coming days perhaps.

a kind soul advised me that if I want to get people interested in the
'Foreach()' macro, I need to _sell_ it.  hence the teaser below (and attached
for convenience).


enjoy, jr.



/* obfusc.pov */

#version 3.8;

global_settings {assumed_gamma 1}

#include "foreach.inc"
#include "logo.inc"

camera {
  location <3.25,0,-4.5>
  direction z
  right x * (4/3)
  up y
  angle 80
  look_at <3.25,0,0>
}

/* the data.  the character codes are obscured 'rot13' style */
#declare A = array {
  array mixed {<0, 1, 0>, .75, 0,
          array {122, 110, 113, 114, 45, 130, 128, 118, 123, 116}},
  array mixed {<0, 0, 0>, 1, 1,
          array {93, 92, 99, 58, 95, 110, 134}},
  array mixed {<0, -1, 0>, .75, 0,
          array {64, 59, 69, 59, 61, 58, 110, 121, 125, 117, 110}}
};

#declare font_ = array {"comic.ttf", "comicbd.ttf"};

/* make plain text */
#macro m_ch(i_,elem_)
  chr(elem_ - 13)
#end

#declare str_ = array [3];

#for (i_,0,2)
  #declare str_[i_] = concat(Foreach(A[i_][3], dictionary {.Macro: "m_ch"}));
#end

/* et voila */
object {
  Povray_Logo
  texture {
    pigment {color rgb <1,1,0>}
    finish {ambient 0 emission 1}
  }
  scale 1.5
  translate <5.3, .3, 0>
}

#macro m_text(i_,elem_)
  text {
    ttf font_[elem_[2]] str_[i_], .1, 0
    texture {
      pigment {color rgb <1,1,0>}
      finish {ambient 0 emission 1}
    }
    scale (<1,1,1> * elem_[1])
    translate elem_[0]
  }
#end

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


Post a reply to this message


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

From: jr
Subject: Re: foreach macro
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)

From: Tor Olav Kristensen
Subject: Re: foreach macro
Date: 26 Apr 2021 21:00:00
Message: <web.608761b7d564bfd48e52cc8789db30a9@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:
> "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?
>...

I don't know.

I just made a macro call itself - and then I got this error after about 99
calls:
"Parse Error: Too many nested symbol tables"

This was with POV-Ray in Ubuntu 20.04.2 LTS:

Persistence of Vision(tm) Ray Tracer Version 3.7.0.8.unofficial (g++ @
x86_64-pc-linux-gnu)
This is an unofficial version compiled by:
 Dimitri John Ledkov <xno### [at] ubuntucom> for Debian <www.debian.org>

Since you don't get the same error message: Could this possible be some other
problem in your code ?

--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

From: jr
Subject: Re: foreach macro
Date: 27 Apr 2021 04:45:00
Message: <web.6087ce41d564bfd479819d986cde94f1@news.povray.org>
hi,

"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> "jr" <cre### [at] gmailcom> wrote:
> > 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?
> >...
> ...
> I just made a macro call itself - and then I got this error after about 99
> calls:
> "Parse Error: Too many nested symbol tables"
>
> This was with POV-Ray in Ubuntu 20.04.2 LTS:
>
> Persistence of Vision(tm) Ray Tracer Version 3.7.0.8.unofficial (g++ @
> x86_64-pc-linux-gnu)
> This is an unofficial version compiled by:
>  Dimitri John Ledkov <xno### [at] ubuntucom> for Debian <www.debian.org>

thanks for checking.


> Since you don't get the same error message: Could this possible be some other
> problem in your code ?

unsure.  there are, now, two problems.  on the nesting issue + error - I read
(but forgot to take notes) that Debian maintainers do not use the '-ffast-math'
flag, so wonder whether it's an optimisation thing.  second prob - I only have a
Debian VM, pre-installed on the Chromebook, v 3.7.0.8 compiled by Andreas B.
that does not like the .inc, parse errors when it hits the '#ifndef (global...)'
etc; which changes did you (have to) make to the file(s), other than version
change?


regards, jr.


Post a reply to this message

<<< Previous 8 Messages Goto Latest 10 Messages Next 10 Messages >>>

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