von dp am 18.Januar 97 um 01:53:51:
zu: Perlen aus dem Strom der Nachrichten im direct_L von Daniel am 22.Dezember 96 um 02:00:59:
Subject: Delete-OOP-like solution for objects As far as I know there's not a lingo command that deletes an object. Thaks in advance. 8-) Bernie (berniecc@hotmail.com) Simply break all references to the object and it will be deleted. This -MikeS =============== Michael Scaramozzino, mikes@dreamlight.com A Lingo object is automatically disposed of when there is no longer *any* Some people delete their references to objects by setting the variable set gmyGroovyObject = 0 I like to use a variable that has never been initialized. I always call it set gmyGroovyObject = gVOID -Ron- on void My favorite, because it requires no extra code away from the point of use: set gMyGroovyObject = value(void) (... assuming you don't have a variable named void.) - Mike Edmunds Actually I'm curious. Is this any better than simply setting it to 0, or is set gMyGroovyObject = 0 Neither method requires any code away from the point of use, and Director's > set gMyGroovyObject = value(void) The main benefit that I could see with the value(void) approach is that it > set gMyGroovyObject = 0 The 0 approach that I usually use in Director is more concise but could be This brings up some subtle questions that I hadn't really considered When a variable of a certain type such as an object pointer is created in Any technical details about how Lingo handles internal variables would be Are there any other subtle reasons for leaning one way or the other that I -MikeS For me it's just personal preference. I don't want to get in the habbit of -Ron-
To: Multiple recipients of list DIRECT-L
In C++ it is "delete". Does anybody knows whether the memory occupied
by a big object is freed by simply using the command
"set oVariable = 0" or there's any other similar way to do it?
means resetting ALL variables that are pointing to it (including any
references in the actorlist etc.), to 0. That will do the trick.
references to it. If you need to delete an object, then remove all
references to the object in question. Also don't forget about the actorList
if you have been using it.
containing the object to 0.
gVOID.
Another solution is to make a do-nothing movie script handler...
end
set gMyGroovyObject = void()
- Glenn M. Picher Dirigo Multimedia gpicher@maine.com
Macromedia Director Engineering
this more of a personal preference issue?
loose typing easily allows putting the integer 0 into what used to hold an
object pointer. Both methods result in releasing the object.
may be a touch more obvious that you are clearing out a pointer. Does this
approach actually release more memory? The memory used for the variable
itself? Does setting it to void release it from the symbol table or
something similar?
a touch more confusing if someone was reading another's code and didn't
quite understand the reason for setting it to 0. This obviously will hold
the integer 0 in memory where it is really no longer needed. If the
vaule(void) approach actually removes the variable as well from memory,
then I'd switch to using that method unless the variable is used again
later and reset to point to an object again which would remove and then
recreate the variable.
before. I really didn't worry too much about such issues since Lingo is not
strictly typed unlike C++.
Lingo it obviously must reserve enough memory to hold such a pointer. Does
subsequently putting an integer or other type of value into the variable
type cast the value to the type of the original variable? Or, does it
create a new variable of the new type (using a different amount of memory
based on the new type)? And does setting it to value(void) actually destroy
the variable itself releasing the variables memory (I'm not talking about
the objects memory, but the memory used by the pointer itself) or simply
set it to some type of null pointer value that does use memory until it
goes out of scope?
useful when considering such issues.
haven't considered?
leaving variables hanging around that contain the value 0. This isn't
ususally bad in Lingo but as you know, in C it can be a bad thing. It's the
whole nil pointer thing. I don't want to carry over bad habbits into lower
level languages.
D. Plänitz