POV-Ray : Newsgroups : povray.newusers : functions and macros : Re: functions and macros Server Time
18 May 2024 00:24:43 EDT (-0400)
  Re: functions and macros  
From: Cousin Ricky
Date: 18 Jun 2023 18:44:01
Message: <648f88b1$1@news.povray.org>
On 2023-06-18 10:58 (-4), kurtz le pirate wrote:
> 
> 114:#declare dayfrac_to_local_hr = function (df, tz) {
> 115:  24.0*limit_zero2one(df + (tz/24.0))
> 116:  }
> 
> and i get this error :
> line 115
> Parse Error: Cannot pass uninitialized identifier as non-optional macro
> parameter.
> 
> [snip]
> 
> Hence the question : Can a function call a macro ?

As Leroy said, the short answer is no.

Technically, it is possible to include a macro in a function definition,
but the macro is evaluated only in the process of defining the function.
 Thereafter, whatever the macro was expanded to *at that particular
time* becomes a permanent part of the function definition.  The macro is
never called from the function itself.

In your case, this means that the parser tries to evaluate df and tz
during the *definition* of the function, at which point df and tz are
undefined because the function is not in the process of being called.
(In Computerese, they are mere formal parameters, with no actual
arguments to back them up.)

So, a macro can be included in the function definition, but it cannot do
what you are trying to do.


Post a reply to this message

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