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 #38191 is a reply to message #38190] Tue, 24 February 2004 13:45 Go to previous messageGo to previous message
Pavel Romashkin is currently offline  Pavel Romashkin
Messages: 166
Registered: April 1999
Senior Member
And what exactly would be the purpose of such sequence of calls, other
than actually trying to *define* foo in the first function call? If I
didn't need foo re-defined, I'd not even mention it on the first line.
So this *is* the case for 3 copy-paste calls, I guess :-)
I never tried to use keywords for this sort of creative purposes. If I
have a large dataset I don't want to re-compute, I keep it in a pointer
(or object, allrigh, David? :-) and I try to always know when it gets
passed into a function to avoid redefinition and other mishaps.
After all, how is this behavior different than simply

foo = 100 ; foo is now defined, too...

If we did want to get funny I suppose we could try

a=myfunc(test,FUNNY_VARIABLE=[foo]) ; foo didn't change

but if foo is BIG, we'd get a dramatic slowdown.
Pavel

JD Smith wrote:
>
> 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: Tue Dec 02 23:54:29 PST 2025

Total time taken to generate the page: 3.21405 seconds