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

Re: Pointers



Robert Leejoice (rleejoice@aol.com) writes:

> What are pointers used for in IDL.  I only precieve that they lead to the new
> object paradyme.  Is this correct?   I use structures in most of my programming
> and pass the complete structure to the appropaite procedures.  I suppose I
> could creat a pointer to a structure, but since IDL passes structures by
> reference, what is the need?  

Pointers are used for all kinds of things, but I think
the most obvious good use of pointers is in structures.
(Or objects, which are implemented as named structures.)

Suppose, for example, that you have a field named IMAGE
in your structure. But the image data that is stored there
might vary in size and data type. Without pointers, you
would have to use an anonymous structure and redefine it
when the image data changed. With pointers, you can continue
to use a named structure with the IMAGE field a pointer to
whatever you like:

   struct = {MYSTRUCT, Image:Ptr_New(image), ...}
   *struct.image = newimage

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