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 #8390 is a reply to message #8356] Thu, 27 February 1997 00:00 Go to previous messageGo to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
JD Smith writes in a follow-up to this thread:

> The question is really about the mechanism of Keyword Checking for built-ins
> vs. non-built-ins. That is, if *I* wrote a routine that took the "THICK"
> keyword, a user could pass an undefined value through THICK and I would never
> know that he did. I could not use n_elements() or keyword_set() or any other
> mechanism I know of to discern in any way that he has used "THICK". And so,
> consequently, I would not be able to issue an error message in the case he
> passed an undefined variable. It is as if he never passed it at all! Not so
> for Plot and other built-in routines (for *some* of their keywords). They
> somehow "know" that I used e.g., "THICK", even when I pass them an undefined
> variable.
>
> My point was that this would be a useful feature to have (although it would
> possibly result in some subtle and harmful programmatic issues). For
> instance, if I pass a variable through a keyword into which I'd like to put
> the result of some calculation, I have to give that variable a value before
> passing it, in order to test whether to go through the bother of doing the
> calculation at all. There are, of course, other ways to do this (e.g.
> optional *parameters*), but I've found myself wishing for this particular
> mechanism on some occassions, when the other techniques had limitations.

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.

Cheers!

David

-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
2642 Bradbury Court, Fort Collins, CO 80521
Phone: 970-221-0438 Fax: 970-221-4762
E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
-----------------------------------------------------------
[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: Fri Oct 10 05:24:18 PDT 2025

Total time taken to generate the page: 0.32080 seconds