[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Why are objects global?
- Subject: Why are objects global?
- From: bjackel(at)phys.ucalgary.ca
- Date: Tue, 18 Jul 2000 12:31:58 -0600
- Newsgroups: comp.lang.idl-pvwave
- Organization: University of Calgary
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:20302
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
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.
<<hypothetical complicated useful code>>