Re: Array elements as named variables? [message #2368 is a reply to message #2360] |
Mon, 27 June 1994 15:11   |
landers
Messages: 45 Registered: May 1993
|
Member |
|
|
In article <2un02p$lm1@lace.Colorado.EDU>, msegur@newton (The Ethereal Knight) writes:
|> Is it possible to used an element of an array as a named variable
|> in order for a procedure to store a value in it?
[snip]
Nope, can't do it. Seems reasonable that you should be able to, since it
points to a single memory location (at least at the time of the CALL, if not
the RETURN, since the varaible referenced could change during the subroutine
processing!...), and you could have used it on the left-hand-side of an
assignment. But...
When you call a procedure, IDL/WAVE decides whether to pass a parameter by
value or by reference (memory address). There is no consideration given to
making assignments upon a RETURN. Only things passed by reference can be
changed, since the location of the actual variable in memory is the same in
the caller and the subroutine.
The reasoning used to decide how to pass a parameter is if it's an expression
or not. Check this by doing HELP (IDL) or INFO (WAVE) like this:
WAVE> info,a
A FLOAT = Array(10)
WAVE> info,a(0)
<Expression> FLOAT = 0.00000
^^^^^^^^^^^^
You want it to decide based on if you could use a reference on the left-hand
side of an expression. Not me. The way it is, I can pass an array to a
procedure like this:
Some_Procedure, a
or like this:
Some_Procedure, a(*)
The procedure gets the same data, but in the second case, I can insure that my
data won't be changed behind my back. Just a matter of perspective.
;Dave
|
|
|