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

Home » Public Forums » archive » About keywords and positional parameters
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: About keywords and positional parameters [message #32790 is a reply to message #32720] Fri, 08 November 2002 12:32 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
JD Smith (jdsmith@as.arizona.edu) writes:

> Just to be clear, I've never actually used this method (using
> arg_present() essentially as an input test) in real-life code... it's
> not really all that helpful. In fact, I wrote it just to get under
> your skin, what with your braggadocious claim that you could never
> know if a keyword is *used* ;). From my perspective, there are only
> three real cases worth keeping track of:
>
> 1. An input keyword: Use n_elements() to see if it's present, or
> keyword_set() if it's intended to be a boolean.
> 2. An output keyword: Use arg_present() if computing the output is
> actually optional in your program, and you want to save the
> trouble of calculating it if the caller didn't ask for it.
> 3. An input/output keyword: Use a combination of the above two,
> reserving n_elements/keyword_set for input tests, and arg_present
> for output tests.

JD and I don't really need to be having this
conversation, because both of us know perfectly
well how to handle keywords correctly (and neither of
us would probably ever have a need to know if a keyword
was "used" or not). But for the sake of completeness, and
for the edification of the 63.58% of IDL programmers
(according to an informal survey I've taken) that use
KEYWORD_SET incorrectly in their programs, I reiterate:
KEYWORD_SET [capitals deliberate] should be used ONLY
for keywords that have Boolean values. :-)

Cheers,

David

P.S. Let's just say that if everyone ripped KEYWORD_SET
out of their code and substituted N_ELEMENTS the world
would probably be a better place. (Or, at the very least,
more functional.)

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Fit a circle ?
Next Topic: slicer3

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

Current Time: Sat Oct 11 19:09:06 PDT 2025

Total time taken to generate the page: 0.96134 seconds