[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Passing optional parameters through a wrapper routine
Mark Hadfield (firstname.lastname@example.org) writes:
> I don't see anything generally wrong with passing variables on without
> knowing what they are or whether they are defined. That's what a wrapper
> routine does -- it concerns itself with some subset of the information
> passed to it and let's the "wrappee" deal with the rest. RSI in their wisdom
> invented inheritance mechanisms to do this with keywords. For a general
> wrapper routine with an unknown number of positional parameters I favour the
> "case n_params()" syntax originally proposed by Kenneth. If I get a chance
> tomorrow I may illustrate this using my (almost completely) general wrapper
> routines that report on the execution time of the wrappee.
There is nothing wrong with "wrapper" routines passing
undefined variables. I often do this too, especially
when I write a wrapper function for an object. But there
is a difference between the wrapper and the wrappee,
as it were. :-)
It just better be the case that when the undefined
variables get to the end of the line that the
program there knows what to do with them. Mine
do, because that is how I choose to write them.
Many of the built-in IDL routines do not. That's
why they issue "undefined variable" errors.
The TVRD command is a perfect example. If those
variable parameters are undefined when they come
into the program, they should be defined as 0, 0,
!D.X_Size, and !D.Y_Size, respectively. That's what
I would do if I were writing the TVRD command.
But since I didn't, and since the best I can do is
write the wrapper for it, I'd probably move the
"intelligence" up one level. :-)
P.S. I guess the CASE N_PARAMS() syntax isn't so bad,
now that I think about it. I just think it *looks* ugly. :-)
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: email@example.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155