lua-users home
lua-l archive

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

Richard Ranft wrote:
C# has a Dispose() which I'm sure forces a
GC flag on the object....  Ok, I'm not "sure," but I think we can make a
strong assumption there.

No no, .NET's Dispose() is just their standardization (sp?) of the interface for releasing resources owned by classes. It isn't directly related to the lifetime of the object.

Something like this could not only mark the object
for deletion but trace back through the reference stack and notify other
constructs that have references to this object that it is about to go away
so that they can request replacement or countermand the deletion.

It is very common for language users to create their own sub-languages, coding conventions, protocols, however you call it. You are free to implement your vision of deletable garbage-collected objects, but I don't think it should be part of the standard Lua system; certainly not with the overhead of what you describe.

A fairly common approach in games and GUI systems is to mark objects as "dead" (i.e. wants to be deleted). Everyone who references them must check for this during regular operations, and eliminate their own reference if the object is flagged as dead. Simple and lightweight.

If Lua shipped with a number of standard classes and libraries, it would probably need to define a larger number of protocols like these.

Javier Arévalo
Pyro Studios