Re: Programming style [message #3369] |
Thu, 19 January 1995 04:30 |
steinhh
Messages: 260 Registered: June 1994
|
Senior Member |
|
|
In article <3fjcbe$2el@due.uninett.no>, lars@rapid.fi.uib.no (Lars
S�raas) writes:
|>
|> Does anybody out there know if IDL passes arguments to functions by
|> value
|> or by refrence? I have developed a programming-style where I tend to
|> pass huge
|> datastructures as parameters and not through common blocks. This is
|> obviously inefficient in the pass-by-value-case, so I might have to
|> change
|> my style.
|>
As a general rule, IDL passes arguments by reference. The only (partial)
exception is when you pass a subset of an array, e.g:
MYPROG,DATA(0:10,*)
; or
MYPROG,DATA(1)
In this case, IDL generates a new "variable" (or rather an expression)
with values taken from the original array (this may involve a lot of
memory shoveling), and passes it to the routine by reference. I.e., the
receiving routine is not able to change the values in the original array
by altering elements in the sub-array that it receives. This is important,
because e.g., READ,DATA(0) doesn't work.
Personally, I agree totally with your programming style - I'm much
happier with passing parameters than using common blocks, even if
there's a slight overhead in sending the reference.
Stein Vidar Haugan
|
|
|