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

Home » Public Forums » archive » Yet again, The Sky is Falling!
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: Yet again, The Sky is Falling! [message #53038 is a reply to message #52940] Mon, 12 March 2007 15:30 Go to previous messageGo to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Sven Geier wrote:
> mgalloy@gmail.com wrote:
>
>> I'm talking about two parameters that are both passed a single named
>> variable (like Paul's mypro example). While legal, I don't think this
>> is a good technique for clear code.
>>
>
> ...and as usual there's exceptions where this is a perfectly good thing to
> do. I have a routine in front of me that dynamically improves a "guess" of
> some number. It takes an input and an output parameter and in almost all
> cases you want to give it the same variable there. Schematically like this
>
> x = someOldGuess
> improve,x,x
>
> where "improve" takes the first "x" as its input, copies the values to a
> local variable, performs a bunch of magic and returns the result in
> the "second x". From the outside, the variable "x" simply has a new,
> improved value (which is the purpose of "improve').

But why do that? It makes no difference since you're overwriting the original value of x
anyway. Why not just do

x = someOldGuess
improve,x

where "improve" just modifies "x" internally as required. The only advantage (that I can
see) of

improve,x,x

over

improve, x

is that the former serves to confuse the reader of the code. There may be examples of
exceptions where the construct in question is a good idea, but this isn't one of them.

> I second David's statement that one of the nice things about IDL is that one
> can do all these weird things. As someone once said (about C++, I
> think) "all the power and all the elegance of a hand grenade": It ain't
> always pretty but it gets things done.

Yes, well, just because something *can* be done....

But I like the analogy - much more graphic than the old "shoot yerself in the foot"
sawhorse. :o)

cheers,

paulv

--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
[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
Read Message
Read Message
Read Message
Read Message
Previous Topic: mpeg creation problem
Next Topic: reading many files

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

Current Time: Fri Oct 10 19:29:12 PDT 2025

Total time taken to generate the page: 7.83569 seconds