POV-Ray : Newsgroups : povray.pov4.discussion.general : A Feature of Possible Use : A Feature of Possible Use Server Time
1 Mar 2024 00:17:40 EST (-0500)
  A Feature of Possible Use  
From: John VanSickle
Date: 21 Apr 2009 07:55:00
Message: <49edb414$1@news.povray.org>
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)
     #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 } }
     #debug "Invalid object passed as Paint parameter to FunHouse().\n"
     #local txtPaint=texture { }
   union {
      /// several objects here to make a fun house
      texture { txtPaint }

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).


Post a reply to this message

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