POV-Ray : Newsgroups : povray.pov4.discussion.general : A Feature of Possible Use : Re: A Feature of Possible Use Server Time
2 Mar 2024 22:02:35 EST (-0500)
  Re: A Feature of Possible Use  
From: Reactor
Date: 21 Apr 2009 14:30:00
Message: <web.49ee0ffd811cc9b481734cd40@news.povray.org>
John VanSickle <evi### [at] hotmailcom> wrote:
> Pardon me if this has already been suggested.
> Most macro writers could make the idiot-proofing of their macros much
> more thorough by having a feature by which it is possible to test an
> argument passed to the macro to determine if it is of the expected type.
> Not only can this be used to give better feedback in an error message,
> macro writers could also use it to make a macro more flexible for the
> end user.
> Here's one I though up just now:
> #macro FunHouse(Paint)
>    #if(type(Paint)="texture")
>      #local txtPaint=Paint;
>    #else_if(type(Paint)="pigment") // yeah, the SDL could use an
>                                      // else-if statement, if it
>                                      // doesn't already have one
>      #local txtPaint=texture { pigment { Paint } }
>    #else
>      #debug "Invalid object passed as Paint parameter to FunHouse().\n"
>      #local txtPaint=texture { }
>    #end
>    union {
>       /// several objects here to make a fun house
>       texture { txtPaint }
>    }
> #end
> I suggest passing a string back only because it's more human-readable
> for comparisons, and more easily allows for future expansion of the
> feature (such as stating whether the object is an array of something, or
> just a something).
> Regards,
> John

Agreed, but I think the type() operator should return a string of the objects
type, in which case you'd have to use string compare.  Being able to determine
the type could also be handy for permitting greater flexibility in macros and
text file reading and writing operations.


Post a reply to this message

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