POV-Ray : Newsgroups : povray.programming : Fuctions : Re: Fuctions Server Time
28 Jul 2024 14:28:33 EDT (-0400)
  Re: Fuctions  
From: Chris Huff
Date: 24 Jul 2000 14:26:32
Message: <chrishuff-2EBA1C.13271124072000@news.povray.org>
In article <B5A119EF.1928%dav### [at] maccom>, David 
<dav### [at] maccom> wrote:

>     I think in the next version of POV (eg 4), there should be real
> functions, not macros.

Why? Functions would be much more restricting than macros, and not any 
more useful.
Don't forget that the current macros don't behave exactly like C 
macros...for example, the parameters are actual variables, not bits of 
text that are cut and pasted into the body. The body *is* copy-pasted, 
which allows a macro to do and generate anything, without needing a 
single return type.

Anyway, isosurface functions already use the "function" keyword. :-)
I think it might be worth it to have these functions be available to 
ordinary calls, like this:
#declare myFunc = function (A=0, B=1){sin(A)*cos(B)}

#declare Val = myFunc(2, 1.6);
#declare Val2 = myFunc(3);
#declare Val3 = myFunc();

This would be most useful if functions could have different numbers of 
parameters, not just 3. The above declaration would have 2 parameters, x 
and y, defaulting to 0 and 1. The default parameter list would be (x, y, 
z), so this would be backward compatible with all existing functions.
And while they would be restricted to scalar values, they would probably 
parse faster than macros.

-- 
Christopher James Huff - Personal e-mail: chr### [at] maccom
TAG(Technical Assistance Group) e-mail: chr### [at] tagpovrayorg
Personal Web page: http://homepage.mac.com/chrishuff/
TAG Web page: http://tag.povray.org/


Post a reply to this message

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