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

Re: undefined keyword variables



Craig Markwardt (craigmnet@cow.physics.wisc.edu) writes:
> 
> Dusting off my degree in horse-beating...

Oh, well, it's a slow day here, too. :-)
> 
> davidf@dfanning.com (David Fanning) writes:
> > 
> > I think it is not only feasible, but required, that you 
> > provide default values for *any* variable you plan
> > to use in the code. Certainly if I were planning to
> > use the POSITION keyword I would have something like this:
> > 
> >    IF N_Elements(thePosition) EQ 0 THEN thePosition=!P.Position
> >    ...
> >    Plot, data, Position=thePosition
> 
> This doesn't always work.  Here is what happens when I examine
> !p.position after starting IDL fresh:
> 
> IDL> print, !version
> { alpha OSF unix 5.2 Oct 30 1998}
> IDL> print, !p.position
>       0.00000      0.00000      0.00000      0.00000

Whoops! Indeed. Case of IDL not being as smart
as it usually is, I think. But, then, this is one
of those keywords that is apparently escaping
scrutiny anyway.

> My point is that *whatever* strategy that IDL uses to pass undefined
> keywords appears to be inconsistent.  It should either be documented
> or corrected.

I shouldn't think they would document it. Too embarrassing.
But I hear they are fixing it, and indeed my IDL 5.3 beta
seems to handle things more gracefully. Although not, alas,
in this specific case. 

But to be fair, checking variables can be a damn nuisance.
I have someone hounding me now about one of the programs
I have on my web page. Even though the documentation 
clearly says use NORMALIZED coordinates, he wants to use
DATA coordinates. So my tick marks are the wrong length.

So...what to do. Enforce the normalized convention when I 
check my keywords, or modify the code to handle a situation
I didn't anticipate? I'll probably modify the code. But
now I have a better idea of how people will use my code
and--yikes!--I have a lot of code out there that could
benefit from my new understanding. Will I change it? 
No, probably not. Not unless someone else starts hounding
me with e-mails. 

But I *might* think about it the next time I'm foolish 
enough to publish something in a public forum. :-)

Cheers,

David
-- 
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155