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

Home » Public Forums » archive » Using NO_COPY with pointers
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Using NO_COPY with pointers [message #34733] Mon, 14 April 2003 08:22
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Folks,

This may be common knowledge, but I wasn't aware of it, and
it is one of those things that makes you feel all warm and
goose-pimply about IDL.

I was adding a "user value" to all of my objects
today, via a UVALUE field in the "atom" object that
is inherited by all objects in my library. This field
is, of course, a pointer.

Naturally enough, I want to be able to get and set
the "value" of this field sometimes without making
a copy of the data. This is no problem when I am
adding the information to the pointer, I simply use
the NO_COPY keyword on PTR_NEW:

self.uvalue = Ptr_New(uvalue, /No_Copy)

But it is a bit of a problem when I want to "get"
the value back:

uvalue = *self.uvalue

I was of the impression that pointer de-referencing
*always* made a copy of the data. But on a whim, I
tried this:

IF Keyword_Set(no_copy) THEN uvalue = Temporary(*self.uvalue)

Lo and behold, this did *exactly* what I wanted it to do!!

Help, *self.uvalue
<PtrHeapVar2093>
UNDEFINED = <Undefined>

Moreover,

Print, Ptr_Valid(self.uvalue)
1

Perfect! A valid pointer that points to an undefined variable.
Hooray! You gotta love IDL! :-)

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Maximum radius of SEARCH2D/SEARCH3D
Next Topic: Envisat ASAR header

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

Current Time: Fri Oct 10 07:24:48 PDT 2025

Total time taken to generate the page: 1.27896 seconds