POV-Ray : Newsgroups : povray.general : Macro with variable number of parameters... : Re: Macro with variable number of parameters... Server Time
29 Jul 2024 12:20:09 EDT (-0400)
  Re: Macro with variable number of parameters...  
From: Matt Giwer
Date: 4 Jul 1999 17:17:03
Message: <377FCF6D.E5B49458@giwersworld.org>
> Is it possible to create a macro with a variable number of
> parameters?
> 
> I'm trying to create a macro that counts the number of
> parameters passed to it and then issue the #macro definition.
> 
> Is this possible?
> 
> I want a way to make it so the user doesn't have to provide
> information that isn't necessary.  Based on the value of the
> first parameter, the second is always needed, but the third
> may not be.  I'd like to allow the user to do the following.
> 
> myMacro(0,"a")
> 
> or
> 
> myMacro(1,"a","b")
> 
> The first and second parameter are needed, but if the first is a 0
> (instead of a 1) the third value isn't necessary.
> 
> Anyone have any ideas?

	IF it is possible, it remains poor programming practice. Either
the first parameter is the number of additional parameters to be
passed or write two macros. Your examples would then pass (1,"a")
and (2,"a","b") Alternatively the passing routine can pass an end
of list marker. 

	It is also a dangerous language that would permit what you want.
FORTH comes to mind. 

-- 
<blink>-------please--don't-----------------</blink>

http://www.giwersworld.org/artii/
http://www.giwersworld.org/artiii/

Finally up on 99/06/22 updated 06/30


Post a reply to this message


Attachments:
Download 'us-ascii' (1 KB)

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