|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I tried to write a macro using optional parameters.
POV-Ray gave me back errors, saying it wanted n parameters, but I only supplied
x.
The number of parameters I specified was n, ranging from 0 to 4.
I tried supplying 0-3, but it seemed to want all 4.
That was with beta 2.
I will supply more info if necessary.
Has anyone else tried running an optional parameter macro?
Can someone post sample code?
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Le 23/03/2017 à 17:03, Bald Eagle a écrit :
> I tried to write a macro using optional parameters.
>
> POV-Ray gave me back errors, saying it wanted n parameters, but I only supplied
> x.
>
> The number of parameters I specified was n, ranging from 0 to 4.
> I tried supplying 0-3, but it seemed to want all 4.
>
> That was with beta 2.
>
> I will supply more info if necessary.
> Has anyone else tried running an optional parameter macro?
>
> Can someone post sample code?
>
Could provide the code you tried first ?
My guess so far is : #version...
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Am 23.03.2017 um 17:03 schrieb Bald Eagle:
> I tried to write a macro using optional parameters.
>
> POV-Ray gave me back errors, saying it wanted n parameters, but I only supplied
> x.
>
> The number of parameters I specified was n, ranging from 0 to 4.
> I tried supplying 0-3, but it seemed to want all 4.
You can omit the optional parameters, but you still have to specify the
commas. For example:
#macro Foo(A, optional B, C)
...
#end
Foo(1,,3)
Currently, this is true even if the optional parameters are at the end
of the parameter list:
#macro Foo(A, B, optional C)
...
#end
Foo(1,2,)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 3/23/2017 3:10 PM, clipka wrote:
> Am 23.03.2017 um 17:03 schrieb Bald Eagle:
>> I tried to write a macro using optional parameters.
>>
>> POV-Ray gave me back errors, saying it wanted n parameters, but I only supplied
>> x.
>>
>> The number of parameters I specified was n, ranging from 0 to 4.
>> I tried supplying 0-3, but it seemed to want all 4.
>
> You can omit the optional parameters, but you still have to specify the
> commas. For example:
>
> #macro Foo(A, optional B, C)
> ...
> #end
>
> Foo(1,,3)
>
> Currently, this is true even if the optional parameters are at the end
> of the parameter list:
>
> #macro Foo(A, B, optional C)
> ...
> #end
>
> Foo(1,2,)
>
That is some weird syntax.
Mike
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Am 2017-03-23 16:09, also sprach Mike Horvath:
> That is some weird syntax.
Indeed.
Although not *completely* unheard of. A C for statement could look
similarly.
int i=0;
for (;;i++)
if (i>10)
break;
I may have gone with "C = -1" instead of "optional C"
I see mysterious namespace collisions in your future.
--
dik
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
#macro Test (optional A, optional B, optional C, optional D)
#debug "Start macro Test \n"
#ifndef (local.A)
#debug "No parameters defined \n"
#end
#ifdef (local.A)
#macro _Test (A, B, optional C, optional D)
#end // end macro _Test
#end
#debug "End macro Test \n"
#end // end macro Test
With Test (1, 2) I get "expected 4 but only found 2", or
with Test (1, 2)
"expected 8 but only found 2"
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Am 24.03.2017 um 12:33 schrieb Bald Eagle:
> #macro Test (optional A, optional B, optional C, optional D)
> #debug "Start macro Test \n"
> #ifndef (local.A)
> #debug "No parameters defined \n"
> #end
That test isn't really accurate. `#ifndef(local.A)` only tells you
whether the first parameter was omitted; parameters B, C and/or D might
still be supplied, as in:
Test(,2,3,4)
Note that POV-Ray's optinal parameters differ from those in C/C++ in
that you can declare _any_ parameter as optional, not just the last
ones. For example, in
#macro Test(optional A, B, C, D)
#end
only parameter A is optional, the others are mandatory.
Also, POV-Ray allows you to pass undefined variables to optional
parameters, e.g.:
#undef Blah
Test(Blah,2,3,4)
> #ifdef (local.A)
> #macro _Test (A, B, optional C, optional D)
>
> #end // end macro _Test
> #end
> #debug "End macro Test \n"
> #end // end macro Test
Defining a macro inside a macro? That's... uh... yeah, /possible/, I guess.
> With Test (1, 2) I get "expected 4 but only found 2", or
>
> with Test (1, 2)
> "expected 8 but only found 2"
That statement of yours doesn't make sense.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|