comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Curious Keywords
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Curious Keywords [message #8356] Mon, 03 March 1997 00:00 Go to previous message
thompson is currently offline  thompson
Messages: 584
Registered: August 1991
Senior Member
davidf@dfanning.com (David Fanning) writes:

> JD Smith writes in a follow-up to this thread:

(stuff deleted)

> JD is absolutely right about this. You cannot tell in an IDL procedure
> if a keyword is *used* or not. You can only tell if the argument to the
> keyword is *defined* or not.

> (Most of the programs I look at, by the way, mistakenly think this
> is what KEYWORD_SET is doing for them. Sigh...)

> Since knowing if a keyword is *used* is often quite useful for
> exactly the reasons JD mentions, I think it should be added to IDL.
> Obviously IDL knows if the keyword is being used.

> I think, if I remember correctly, that PV-Wave has a function
> entitled KEYWORD_USED (or something like it) that does this very thing.


On the other hand, I find it quite frustrating that I can't use a phrase like

IDL> plot, findgen(100), findgen(100)/99.*2*!PI, THICK=THICK

and not worry about whether or not THICK was defined. In some sense this is
what _EXTRA does, but that has its own limitations.

Of course, there have been instances when I wanted to do exactly what JD Smith
was talking about. The most obvious example is when I wanted error messages to
be returned to the user rather than printed on the screen. The only way to do
this was to force the calling routine to define the keyword before calling the
program, e.g.

ERRMSG = ''
MYROUTINE, ERRMSG=ERRMSG, ...
IF ERRMSG NE '' THEN ...

As pointed out, this is a pain.

In summary, I guess what would be best would be if the built-in routines were
more forgiving about passing undefined keywords, and also if there were a
KEYWORD_USED (or whatever) routine that would allow .PRO files to figure out
for themselves whether or not a keyword was really passed, even if undefined.
That way, we could eat our cake and have it too.

I would also like to echo David's comment about KEYWORD_SET(). I also find it
upsetting when people use this when they should have used N_ELEMENTS() instead.
(Double sigh.)

Bill Thompson
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: The intersection of 2 arrays
Next Topic: Re: WTB 3D graph on an irregular grid

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 15:31:59 PDT 2025

Total time taken to generate the page: 1.67787 seconds