Re: Curious Keywords [message #8394 is a reply to message #8390] |
Thu, 27 February 1997 00:00  |
kspencer
Messages: 21 Registered: December 1993
|
Junior Member |
|
|
John-David Smith <jdsmith@astrosun.tn.cornell.edu> writes:
> Hi folks,
> A Keyword question:
> I was curious how IDL built-ins can distiguish a passed keyword with an
> undefinded variable from a keyword never passed at all, and why this
> feature is not implemented in the language itself.
> E.G. :
> I can say (for some undefined variable UNDEF):
> plot, findgen(100), findgen(100)/99.*2*!PI,POLAR=UNDEF
> and get a straight line. (Or I can set UNDEF=1 and get a spiral o'
> Archimedes).
> I cannot, however, say:
> plot, findgen(100), findgen(100)/99.*2*!PI, THICK=UNDEF
> Since this generates an "a undefined" error message. This implies that
> plot *knows* I am using the keyword "THICK", even when I am passing an
> undefined variable -- a possibility which most of us discovered the hard
> way is not implementable in IDL code. That is, if IDL's plot routine
> were written in IDL code, the previous call would be equivalent, for all
> practical purposes, to a call in which the keyword were ommitted.
> Any thoughts?
> JD
The reason for this behavior is that the default value of UNDEF in both
cases is 0. For the POLAR keyword, supplying a 0 means don't do anything,
so it doesn't. But supplying 0 to THICK generates an error because the
line has to have *some* thickness to it.
Dig?
Kevin
-----------------------------------------------------------
Kevin Spencer
Cognitive Psychophysiology Laboratory and Beckman Institute
University of Illinois at Urbana-Champaign
kspencer@p300.cpl.uiuc.edu
-----------------------------------------------------------
|
|
|