[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: undefined keyword variables




davidf@dfanning.com (David Fanning) writes:
> 
> Mark Fardal (fardal@weka.astro.umass.edu) writes:
> 
> > A question: should you always be able to pass undefined variables as
> > keywords to IDL routines?
> 
> Oh, this is absolutely normal behavior. (At least under the
> usual standards by which such things are judged in IDL.)
> Is it *correct* behavior? Don't know. But I would doubt it.
> Seems to me *any* optional input keyword should be capable of 
> accepting an undefined variable as an argument. I would run
> it by RSI for confirmation.
> 
> > In general I don't know why you should be able to safely feed
> > undefined variables to routines and expect them to work.  
> 
> Well, because you expect decent programmers to test any
> variable they expect to receive and define default values
> if one is not passed in. (As well as testing for data type
> and structure, but who among us does this except under
> exceptional conditions?)

I am never sure any more how undefined keywords are passed.  It seems
to make a difference whether it's a built-in routine, or an IDL
routine.  It seems to make a difference whether it's IDL 4 or 5.  It
seems to make a difference if you refer to the variable by name before
calling the procedure (not necessarily setting its value).  All these
factors make it hard to handle pass-through keywords consistently.  It
would be nice (no, crucial!) to have this more carefully documented by
RSI.

As to David's suggestion to define default values, that's not always
feasible.  What about the POSITION keyword?  If it's not defined then
you want to rely on IDL's standard positioning.  No default should be
required!

Craig


-- 
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------