|
![](/i/fill.gif) |
Warp <war### [at] tag povray org> wrote:
> posfan12 <nomail@nomail> wrote:
> > #macro randsign()
> > #if (rand(HPlanet_Seed_Value) > 0.5)
> > 1
> > #else
> > -1
> > #end
> > #end
>
> It's not a bug, but by design (even though it might not be intuitive.)
>
> You have to assign the value you want to "return" from the macro to a
> local variable and then have the name of that variable as the last thing
> in the macro.
>
> --
> - Warp
>I have guessed that we had overlooked something. But is this issue really mentioned
within the documentary? A document
ary which is still closed to the users right now. And called a Wiki ...
Best regards,
Michael
Post a reply to this message
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
Warp <war### [at] tag povray org> wrote:
> It's not a bug, but by design (even though it might not be intuitive.)
>
> You have to assign the value you want to "return" from the macro to a
> local variable and then have the name of that variable as the last thing
> in the macro.
>
> --
> - Warp
Awesome, thanks!
Mike
Post a reply to this message
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
Warp <war### [at] tag povray org> wrote:
> It's not a bug, but by design (even though it might not be intuitive.)
Btw, with "by design" I don't mean that the developers deliberately
chose to make macros work like that on purpose, while discarding
alternatives. It's more like macros were tacked onto the existing SDL
parser (the SDL parser has existed for a lot longer than #macros), and
the way in which it parses has this kind of side-effect, and it was
decided to leave it as it is. It may not be the most intuitive way
of "returning a value" (if you can call it as such) from a macro, but
it works with the current SDL parser as it was originally designed.
I think that making macros work more intuitively in this regard would
have required too large of a refactoring job of the entire parser.
There are other curious side-effects of how the SDL parser works, some
of them beneficial, and which are relatively little-known.
For example, if you read values from a file using #read, said file
can have #declare statements in it, and they will be parsed normally
(as if they had been #included.) It's just a side-effect of using the
same SDL parser to implement #read.
--
- Warp
Post a reply to this message
|
![](/i/fill.gif) |