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

Home » Public Forums » archive » Re: Why are objects global?
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: Why are objects global? [message #20687] Wed, 19 July 2000 00:00 Go to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
bjackel@phys.ucalgary.ca wrote:
>
> Subject line says it all.
>
> I've been playing with objects (not object graphics) for a
> while now, and can see how they might be useful. However,
> having to call "obj_destroy" manually at the end of functions
> and routines has been the source of many headaches.
>
> For example, consider the procedure below. It creates
> a "vector3" object which is used for various useful
> calculations, but is of no further use outside "example".
> Once we exit "example", variables "a" and "b" are automatically
> cleaned up. However, "c" gets leaked, unless we explicitly
> destroy it.
>
> Previously, variables in routines would be local unless
> 1) linked to a parameter or keyword
> 2) placed in a common block
> 3) attached to a pointer
>
> Why must objects be any different?
>
> I would argue that they should be treated the same as
> any other variables: cleaned up at the end of a procedure
> or function, unless one of the three conditions mentioned
> above is met. The current behaviour adds complexity to
> IDL, with no obvious advantages.
>
> Brian
>
>

ok. Consider the following: You create a container object somwhere
within a program,
then you call a subroutine to create some object which shall be stored
in the
container. Although that object is never passed into or out of the
routine, you
certainly want to keep it "alive":

; pseudo example

pro make_contents, theContainer

; theContainer is the object reference of the container object
rectangle = obj_new('grSymbol',bounds=,[0.,0.,1.,1.])

theContainer->Add(rectangle)
end

; main
theContainer = obj_new('IDL_Container')
make_contents,theContainer
help,theContainer->Get(index=0)
end



Martin

--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Dr. Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 41173-298 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[Message index]
 
Read Message
Read Message
Previous Topic: Re: Horizontal dotted lines using PLOTS
Next Topic: Unix->Mac transition

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

Current Time: Fri Oct 10 10:14:52 PDT 2025

Total time taken to generate the page: 0.80387 seconds