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

Home » Public Forums » archive » Re: Optional 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: Optional parameters [message #38192 is a reply to message #38191] Tue, 24 February 2004 12:13 Go to previous messageGo to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Tue, 24 Feb 2004 10:59:29 -0700, Pavel Romashkin wrote:

> I agree. I never had a problem with this because I never put unneeded
> variables in a call to a procedure. I fail to see the logic in putting
>
> myfunction, var1=uselessvar
>
> as opposed to just
>
> myfunction
>
> and then worrying about uselessvar getting defined all of a sudden. The
> only time this might happen in real life I suppose is if you use
> copy-paste to insert function calls that address all of the provided keywords.

I'd offer another real life example where read-write keyword variables
can get you into trouble. When you call a function several times in a
row, expecting the same results each time, but in actuality the
keyword variable is defined after the first invocation, which can
change the function's behavior:

a=myfunc(test,FUNNY_VARIABLE=foo) ; foo undefined
a=myfunc(test,FUNNY_VARIABLE=foo) ; foo defined
a=myfunc(test,FUNNY_VARIABLE=foo) ; foo defined

For this reason, I try to make keywords either exclusively read
(i.e. pass in a value), or exclusively write (i.e. return a value),
and not both. It is rather convenient, though, to append a keyword
for the sole purpose of keeping some expensive-to-compute data around
between calls to the function: this is usually where I get tripped up.

JD
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: pointer and structure stuff ...
Next Topic: Re: Something similar to a "Widget_Container" ?

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

Current Time: Fri Oct 10 19:28:46 PDT 2025

Total time taken to generate the page: 1.68429 seconds