POV-Ray : Newsgroups : povray.general : #macros-- a simple question : Re: #macros-- a simple question Server Time
28 Apr 2024 16:10:30 EDT (-0400)
  Re: #macros-- a simple question  
From: Kenneth
Date: 9 Jul 2017 14:55:00
Message: <web.59627b4d1c20efa6883fb31c0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
>
Thanks to you both, for clearing this up (and for testing it in 3.62.)
>
> A macro must always be defined before it is /actually/ invoked. So the
> following will /not/ work:
>
>     Foo()
>     #macro Foo()
>       #debug "in Foo\n"
>     #end
>
The above should be included in the documentation, IMO. It clarifies the basics
of how to write a macro and its call.

> Note that it's the time of definition and invocation that matters, not
> the location within the code. So the following example is perfectly fine:
>
>     #macro Bar()
>       Foo()
>     #end
>     #macro Foo()
>       #debug "in Foo\n"
>     #end
>     Bar()
>
> Here, the call to `Foo()` is placed before the definition, but it's not
> actually invoked there; instead, that invocation is delayed until
> `Bar()` is invoked, which happens after `Foo()` is already defined.
>
Yes, perfectly clear now. (Perhaps *that* kind of example is what I was thinking
of, from the past(?))

Here's the strange part of all this, personally speaking: I can almost visualize
writing a scene file years ago where *something* in the code did not have to be
written in a typical 'linear' way. (I thought for sure that it was a macro-- but
what else it could have been, I have no clue.) The memory of it is quite
clear(!)... (well, it's obviously a *faulty* memory...)


Post a reply to this message

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