POV-Ray : Newsgroups : povray.general : How recursive are #macros ? Server Time
16 Nov 2024 09:19:34 EST (-0500)
  How recursive are #macros ? (Message 1 to 10 of 12)  
Goto Latest 10 Messages Next 2 Messages >>>
From: Peter Popov
Subject: How recursive are #macros ?
Date: 15 Sep 1998 16:45:18
Message: <35fec3ce.0@news.povray.org>
As the subject indicates, I am curious just how many levels of recursion can
one do with a 3.1 #macro. I want to play around with the Mandelbrot / Julia
set, but POV crashes at higher iteration settings (50+). Has anyone explored
the depth of the problem and/or have a solution / workaround? Thanks in
advance,

Peter


Post a reply to this message

From: Ron Parker
Subject: Re: How recursive are #macros ?
Date: 15 Sep 1998 17:02:18
Message: <35fec7ca.0@news.povray.org>
On Tue, 15 Sep 1998 22:35:32 +0300, Peter Popov <pet### [at] usanet> wrote:
>As the subject indicates, I am curious just how many levels of recursion can
>one do with a 3.1 #macro. I want to play around with the Mandelbrot / Julia
>set, but POV crashes at higher iteration settings (50+). Has anyone explored
>the depth of the problem and/or have a solution / workaround? Thanks in
>advance,

If macros are implemented in 3.1 in about the same way they are in the
isosurface patch, then the recursion limit on macros is the same as the 
recursion limit on include files, so that (# of includes + # of macros)
can't be greater than 10.  Of course, there are significant differences 
between the syntax of the two methods, so it's possible that the 3.1 
implementation is more flexible.  It's also possible that they increased
the limit on the number of include files, since changing it is just a 
matter of changing a single number in tokenize.h and recompiling.


Post a reply to this message

From: Thomas Willhalm
Subject: Re: How recursive are #macros ?
Date: 16 Sep 1998 03:57:50
Message: <qqmbtogr1ci.fsf@goldach.fmi.uni-konstanz.de>
"Peter Popov" <pet### [at] usanet> writes:

> As the subject indicates, I am curious just how many levels of recursion can
> one do with a 3.1 #macro. I want to play around with the Mandelbrot / Julia
> set, but POV crashes at higher iteration settings (50+). Has anyone explored
> the depth of the problem and/or have a solution / workaround? Thanks in
> advance,
> 
> Peter

(Since there isn't a Unix version of POV-Ray 3.1b, I can't try it myself.)
Is it possible to nest macro declarations with other declarations and
while-loops? Then you should try to implement the calculation of the
Mandelbrot/Julia set in a non-recursive way.

I hope this helps.

Thomas

-- 
http://www.fmi.uni-konstanz.de/~willhalm


Post a reply to this message

From: Remco de Korte
Subject: Re: How recursive are #macros ?
Date: 16 Sep 1998 09:36:50
Message: <35FFAF10.5DB9090E@xs4all.nl>
Peter Popov wrote:
> 
> As the subject indicates, I am curious just how many levels of
> recursion can
> one do with a 3.1 #macro. I want to play around with the Mandelbrot /
> Julia
> set, but POV crashes at higher iteration settings (50+). Has anyone
> explored
> the depth of the problem and/or have a solution / workaround? Thanks
> in
> advance,
> 
> Peter

I still have to install 3.01 but my guess it is a similar problem as
with recursive programming: you simply use to much memory. I don't know
how this is with POV-macros. With C or Pascal it depends on the amount
of variables you want to pass recursively AND the depth.

Remco


Post a reply to this message

From: Ken
Subject: Re: How recursive are #macros ?
Date: 16 Sep 1998 09:43:43
Message: <35FFB2CD.BF825C02@pacbell.net>
I seem to recall the docs stating you may nest any level of
macros you so desire, the same as you may with while loops.
Of course you can check the docs on this and try to disprove
what I've said here : )

Ken

Peter Popov wrote:

> As the subject indicates, I am curious just how many levels of recursion can
> one do with a 3.1 #macro. I want to play around with the Mandelbrot / Julia
> set, but POV crashes at higher iteration settings (50+). Has anyone explored
> the depth of the problem and/or have a solution / workaround? Thanks in
> advance,
>
> Peter


Post a reply to this message

From: Ron Parker
Subject: Re: How recursive are #macros ?
Date: 16 Sep 1998 10:49:56
Message: <35ffc204.0@news.povray.org>
On Wed, 16 Sep 1998 05:45:01 -0700, Ken <tyl### [at] pacbellnet> wrote:
>I seem to recall the docs stating you may nest any level of
>macros you so desire, the same as you may with while loops.
>Of course you can check the docs on this and try to disprove
>what I've said here : )

If they state this, either they're wrong or the implementation
of while loops has changed in 3.1.  In 3.02, the limit is 200 
or so active conditionals, including ifs, ifdefs, and while loops.


Post a reply to this message

From: Peter Popov
Subject: Re: How recursive are #macros ?
Date: 16 Sep 1998 14:05:11
Message: <35ffefc7.0@news.povray.org>
Ken wrote in message <35FFB2CD.BF825C02@pacbell.net>...
>I seem to recall the docs stating you may nest any level of
>macros you so desire, the same as you may with while loops.
>Of course you can check the docs on this and try to disprove
>what I've said here : )
>
>Ken
>


Docs are one thing and reality is always slightly differerent. It seems to
me #macros have the same problem as max_trace_level which causes crashes at
higher values, however the latter is documented. "The number of known bugs
is limited but not so with unknown ones which are, by definition, infinitely
many" (one of Murphy's laws regarding computers) What I am saying is that I
have read the docs and therefore happily went about doing an animated M set
like the one I posted in binaries.animation, but made of spheres or other
objects. The problem is, as I said, that higher levels of recursive calling
of a #macro calling causes a GPF. There's probably no solution to this
problem, but I found a workaround: I downloaded fractal.inc I found on
Twyst's site and it uses no #macro, so I guess I'll just have to take take a
serious look at the code and do something similar.

Thanks to all for your input.

Peter

P.S. My M-set problem is solved but the original question remains open. How
recursive are #macros ?


Post a reply to this message

From: Ken
Subject: Re: How recursive are #macros ?
Date: 16 Sep 1998 14:22:16
Message: <35FFF416.8289C917@pacbell.net>
Peter Popov wrote:

> Peter
>
> P.S. My M-set problem is solved but the original question remains open. How
> recursive are #macros ?

  What is the difference between nesting and recursion ?
I just looked at the docs and they state emphaticaly that
nesting macros is a no no.

Ken


Post a reply to this message

From: Peter Popov
Subject: Re: How recursive are #macros ?
Date: 16 Sep 1998 15:20:47
Message: <3600017f.0@news.povray.org>
Ken wrote in message <35FFF416.8289C917@pacbell.net>...
>
>  What is the difference between nesting and recursion ?
>I just looked at the docs and they state emphaticaly that
>nesting macros is a no no.
>
>Ken


//Nesting example:
#macro Marco1 ( center1, r1)
  sphere ( center1, r1 )
  #macro Macro2 ( center2, r1);
    cylinder { center1, center2, r2 }
  #end
  #local vector1 = center1 + 5*y;
  Macro2 ( vector1, r1 )
#end

//And here's a recursion example
#macro Macro3 (n)
  #if ( n > 0 )
    #local m=n-1
    Macro3 ( m )
  #end
#end

The first is forbidden, the second is allowed. Both are dumb and useless :)

Peter


Post a reply to this message

From: Scott Hill
Subject: Re: How recursive are #macros ?
Date: 23 Sep 1998 13:07:03
Message: <01bde307$ced53f40$8c00a8c0@shindo>
Peter Popov <pet### [at] usanet> wrote in article
<3600017f.0@news.povray.org>...
> 
> Ken wrote in message <35FFF416.8289C917@pacbell.net>...
> >
> >  What is the difference between nesting and recursion ?
> >I just looked at the docs and they state emphaticaly that
> >nesting macros is a no no.
> >
> >Ken
> 
> 
> //Nesting example:
> #macro Marco1 ( center1, r1)
>   sphere ( center1, r1 )
>   #macro Macro2 ( center2, r1);
>     cylinder { center1, center2, r2 }
>   #end
>   #local vector1 = center1 + 5*y;
>   Macro2 ( vector1, r1 )
> #end
> 
> //And here's a recursion example
> #macro Macro3 (n)
>   #if ( n > 0 )
>     #local m=n-1
>     Macro3 ( m )
>   #end
> #end
> 
> The first is forbidden, the second is allowed. Both are dumb and useless
:)
> 

	Neither are dumb nor useless, granted you can usually achieve the same
effect in a non-recursive or non-nested matter, but there are some
algorithms that are a nightmare to implement non-recursively, and nested
macros would be ideal in situations where you wanted to define a macro that
was only 'in-scope' for the duration of the parent macro.

-- 
Scott Hill
Sco### [at] DDLinkscouk
Software Engineer (and all round nice guy)
Author of Pandora's Box
Company homepage : http://www.ddlinks.demon.co.uk

"The best trick the devil ever pulled was convincing people he didn't
exist..."
								- Verbal Kint.

"the Internet is here so we can waste time talking about nothing in 
 particular when we should be working" - Marcus Hill.


Post a reply to this message

Goto Latest 10 Messages Next 2 Messages >>>

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