lua-users home
lua-l archive

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


> I'm asuming when the PUC guys say "accesible=live" they mean it, I'm
> not even assuming slots or anything similar exists.

I am afraid there is some wishful thinking here. "accessible=live"
doesn't mean too much without a good definition of "accessible", which
is mostly equivalent to a good definition of "live".


> > Java and C/C++ compilers also perform "deletion" of unused variables, by reusing their storage slots for other variables.
> 
> Yes, but they are careful to preserve the semantics of the language.

Similarly here. As long as the semantics of the language does not
dictate when finalizers run, changing when they run do not change the
semantics of the language.

Trying to refrase what Gé already said (and what I tried to say without
success): In Lua code, if you have to think about *when* a finalizer
will run, this is a smell in the code. The only restriction you should
assume is that, in normal code, if the code needs a resource (a file,
for instance), that resource should not have been finalized.

Note that even "the code needs a resource" is something to the language
to decide.

Files are the perfect example. As long as the code may read from or
write to the stream, that stream should not be finalized. As long
as it is impossible (for normal code) to read or write the stream,
it can be finalized. And nobody has to think much about that.

-- Roberto