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

Home » Public Forums » archive » Re: Pass by value and performance
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: Pass by value and performance [message #46794 is a reply to message #46703] Wed, 14 December 2005 22:56 Go to previous message
Antonio Santiago is currently offline  Antonio Santiago
Messages: 201
Registered: February 2004
Senior Member
Kenneth P. Bowman wrote:
> Perhaps someone can clarify this for me.
>
> I was doing this
>
> data = {values : FLTARR(...), $
> other : other stuff ...}
>
> Then pass "data" to a procedure and do this
>
> result = INTERPOLATE(data.values, x, y, z)
>
> In this case data.values is passed by reference. (p. 92 of Building IDL
> Applications)
>

Be carefull (p. 93 of Building ...)

Note:
IDL structures behave in two distinct ways. Entire structures are
passed by reference, but individual structure fields are passed by
value. See Parameter Passing with Structures on page 189 for
additional details.

>
> If I were to use pointers, I could do something like this instead
>
> data = {values : PTR_NEW(FLTARR(...)), $
> other : other stuff ...}
>
> Pass "data" to a procedure and do this
>
> result = INTERPOLATE(*data.values, x, y, z)
>
> Is *data.values passed by reference or by value? And how does one tell?
>

I suposse yes. In the previous example:
PRO JUNK, var
var = var * 5
END

And:

IDL> a = Ptr_New(5)
IDL> junk, *a

I like to understand pointers in IDL in this way:

1.- 'a' is a conventional variable managed by IDL and its "garbage
collector".

2.- '*a' is a HEAP variable, where 'a' stores a reference to it. Also,
the content of the variable 'a' is stored in the heap memory.

Then 'a' is a reference for a "normal" variable that stores a reference,
and '*a' is a reference to a HEAP variable that stores a 5.


junk, *a --> The content of the HEAP memory variable is pased by value.

An then:

*a = *a * 5 is the same as b = b * 5

the diference is first is a HEAP variable and the second is a convential
memory variable.

>
> Ken

Really, I have never question this until I saw your post. These are the
good things of the net :)


--
-----------------------------------------------------
Antonio Santiago P�rez
( email: santiago<<at>>grahi.upc.edu )
( www: http://www.grahi.upc.edu/santiago )
( www: http://asantiago.blogsite.org )
-----------------------------------------------------
GRAHI - Grup de Recerca Aplicada en Hidrometeorologia
Universitat Polit�cnica de Catalunya
-----------------------------------------------------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: idl job posting
Next Topic: Recursive Function Program in IDL

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

Current Time: Fri Oct 10 15:37:33 PDT 2025

Total time taken to generate the page: 0.56136 seconds