|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Chris Huff wrote in message ...
> > > This shouldn't be too hard, since it is apparently possible to
trick
> > > the parser into allowing this already.
> > what about checking parameters count ?
>
> I'm not sure what you mean.
you said about trick,
you mean this from p.u-p ?
what about overdefined declaration
with different number of parameters ?
this could cause unexpected error
(or expected by me in source code)
I think it should be possible without trick
ABX
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
In article <3a0d736f@news.povray.org>, "Wlodzimierz ABX Skiba"
<abx### [at] abxartpl> wrote:
> >In other words, allowing the function to be called in ordinary scene
> >code...
>
> yes
>
> >this should be pretty easy
>
> I hope
I am thinking something like this, in the Parse_Num_Factor() function in
express.c:
#include "isosrf.h"
...
CASE(FUNC_ID_TOKEN)
{
DBL result = 0;
int i=0;
VECTOR Point;
FUNCTION * TFunc = NULL;
Load_Function(TFunc, ((FUNCTION *)Token.Data)->func_name);/*?*/
GET(LEFT_PAREN_TOKEN)
Parse_Vector(Point);
GET(RIGHT_PAREN_TOKEN)
if(TFunc != NULL)
result = (TFunc->iso_func)(TFunc, Point);
for(i=0; i < *Terms; i++)
Express[i] = Val;
}
END_CASE
I don't know if this will work(it compiles, but it hasn't been tested),
and I have no idea what Load_Function() does...but it's a start.
--
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Chris Huff wrote in message ...
>I don't know if this will work(it compiles, but it hasn't been tested),
>and I have no idea what Load_Function() does...but it's a start.
I will check your idea, thanks
ABX
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Chris Huff wrote in message ...
>In article <3a0d736f@news.povray.org>, "Wlodzimierz ABX Skiba"
><abx### [at] abxartpl> wrote:
>> I think that there should be also some max_recursion_level
>> perhaps in global_settings
>
>Probably a good idea, infinite recursion is going to be the most common
>error with recursive functions and hard coded limits are simply annoying
>when you run into them.
It should include an option to allow unlimited recursion for those who know
what they are doing.
Mark
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
In article <3a0f905a@news.povray.org>, "Mark Wagner"
<mar### [at] gtenet> wrote:
> It should include an option to allow unlimited recursion for those
> who know what they are doing.
Umm, unlimited recursion would take an unlimited amount of time and
memory, it's better to let a function hit a limit and produce a parse or
render time error. Even those who know what they are doing would never
use this option...there is no reason I can see to let this "safety net"
be removed.
It would be nice if you could adjust the max nesting level of macros too.
--
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
|
|
| |
| |
|
|
|
|
| |