[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A strange behaviour of parameters passing



William Daffer (vapuser@catspaw.jpl.nasa.gov) writes:

>   There's nothing wrong with passing expressions, unless you want to
> change the value of the parameter inside a routine. It would be nice
> if they gave us some way of checking whether an expression, rather
> than a named variable, had been passed in. I am unaware of any such
> capability.
>   
>   I don't think you can call this is a bug; I think it's a feature. 

While we are on the subject of passing by reference (IDL variables)
and passing by value (anything else, including expressions, system
variables, structure de-references, etc.), I should just point out
that this is *exactly* why this expression does NOT work in IDL:

   FOR j=0, 10 DO Readf, lun, variable[j]

Although, I have to admit, it is an expression that every one
of us has used at least once (and many times if we come to IDL
from a FORTRAN background). People are still confused about why
it produces no error message (Answer: because it actual *works*),
and still returns no useful information.

In fact, here is a riddle Bilbo could have used with Smaug:

   What works perfectly in IDL, but gives you no useful
   information?

   Answer: Reading into subscripted variables!

Cheers,

David

-- 
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155