POV-Ray : Newsgroups : povray.beta-test : recursion with no recursion : Re: recursion with no recursion Server Time
30 Jul 2024 02:18:12 EDT (-0400)
  Re: recursion with no recursion  
From: Thorsten Froehlich
Date: 22 Jan 2002 11:08:31
Message: <3c4d8e7f@news.povray.org>

Skiba <abx### [at] babilonorg>  wrote:

>> The function E exists "twice", once as a local function and once as a global
>> function.
>
> Yes, I noticed this. And it is not very big problem for me to avoid such
> situations but I prefer to report it and get official answer to create some
> kind of background for future newbies. This case appeared for me when I
> translated code from MegaPOV to 3.5 so if anybody maintains tutorial of such
> translation...

The actual root of all these restrictions is that different nature of
functions.  While they are declared like anything else they have the unique
ability to exist after parsing.  This basically forces them into a separate
namespace, which, while parsing is the same as that of the parser, but when
actually "compiling" a function only the namespace of the functions is
available as they "sit on top of the parser" (the code really does, too!)

This creates other funny situations:

#declare foo=function{x}
#declare foo2=function{foo(x,0,1)}
#undef foo
#declare foo=function{x}

Now, what does this do?  Well, there are actually two functions "foo" now,
however, the name of the first function foo has been forgotten by the parser
while the function VM still remembers the actual function, but without a
name (internally functions are tracked via unique numbers).

However, should someone later to a "#undef foo2", the original foo will also
cease existing.  This not only reduces memory consumption, but it also helps
to stay in the limit of 65535 unique functions per scene.

The example above and other very strange cases were the reason why
originally redeclaring functions wasn't allowed in 3.5.  There is an
enormous overhead while parsing but only then!) function to make sure there
are no inconsistencies and there are no orphan functions or functions that
get accidentally replaced by redeclaring them (I think redeclaring would
replace the previous function in MegaPOV when rendering).

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

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