POV-Ray : Newsgroups : povray.programming : complicated functions : Re: complicated functions Server Time
28 Jul 2024 20:30:52 EDT (-0400)
  Re: complicated functions  
From: Chris Huff
Date: 11 Nov 2000 15:07:21
Message: <chrishuff-7A3197.15072911112000@news.povray.org>
In article <3a0d7ee9@news.povray.org>, "Wlodzimierz ABX Skiba" 
<abx### [at] abxartpl> wrote:

> you said about trick,
> you mean this from p.u-p ?

The "trick" was something like:
#declare Func = function {1}
#declare Func = function {if(z, Func(x, y, z-1), moof)}


> what about overdefined declaration
> with different number of parameters ?
> this could cause unexpected error
> (or expected by me in source code)

If a function calls itself with the wrong number of parameters, it 
certainly should produce an error...just like any other function call.


> I think it should be possible without trick

Definitely. What I meant was that since it is already possible, it 
shouldn't be very difficult to make it work without that 
double-declaration trick. Maybe just creating a "dummy" function with 
the same name and parameters just before parsing the body of the 
function would work...

This:
#declare Func = function(r) {Func(r-1)}

Would do this:
1: Parse function parameter list
2: Create dummy function: Func = function(r){0}
3: Parse body of function: Func = function(r){Func(r-1)}

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

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