POV-Ray : Newsgroups : povray.general : How recursive are #macros ? : Re: How recursive are #macros ? Server Time
13 Aug 2024 11:18:23 EDT (-0400)
  Re: How recursive are #macros ?  
From: Scott Hill
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

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