POV-Ray : Newsgroups : povray.general : declare a variable in a function : Re: declare a variable in a function Server Time
23 Jun 2021 02:34:29 EDT (-0400)
  Re: declare a variable in a function  
From: Tor Olav Kristensen
Date: 2 Apr 2021 15:05:00
Message: <web.60676a37db16780d6f19eb189db30a9@news.povray.org>
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> ingo <ing### [at] tagpovrayorg> wrote:
> > i.i.r.c. there is/was a way to declare a variable in a function. But how?
> > I don't remember and can't find it in the remnants of my archive.
>
> You can not have variables that are local to the function. (And you can not have
> any declarations of variables inside the function that are executed when you
> call the function.) If a function is created within a macro, it can access
> variables that are local to the macro. But be aware, because the scope of
> function names are problematic and not well documented in POV-Ray.
>...

At the end of the thread below you can find an example with an array of
functions in a macro. In that example a similar technique is used. Each
function, starting with the last one, calls the one before it until the
convergence criterion has been reached or the first function has been reached.

Newsgroup: povray.advanced-users
Date: 2003-05-02 09:53:29
Subject: Use of povray functions to make fractals other than "famous" Mandelbrot
with same scalability?
Author: Greg M  Johnson
http://news.povray.org/povray.advanced-users/thread/%3Ccjameshuff-CBB1E4.15064403052003%40netplex.aussie.org%3E/

As Hans Mikelson mentioned in that thread; This is "fake" recursion.
I'm not sure if real recursive functions are now safe to use in POV-Ray.
IIRC they were at some point not safe to use and could cause POV-Ray to crash.

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


Post a reply to this message

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