lua-users home
lua-l archive

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



On May 21, 2014, at 3:11 PM, Coda Highland <chighland@gmail.com> wrote:

On Wed, May 21, 2014 at 3:07 PM, Philipp Janda <siffiejoe@gmx.net> wrote:
Am 21.05.2014 21:04 schröbte Tim Hill:


On May 20, 2014, at 6:49 PM, Philipp Janda <siffiejoe@gmx.net> wrote:


They are collected in the reverse order that they were marked for
finalization[1] (usually by setting the metatable), so B will always be
collected before A if both become garbage at the same time, because it was
created/marked last.


I’m not sure this is true; the Lua docs say “in the reverse order
they were marked for COLLECTION” (not finalization). So my reading is
that the order depends entirely on the order in which the GC
determines objects to be unreachable, and (in my reading of it at
least) I don’t see a clear guarantee of that ordering in the docs.


Good point. The wording is definitely ambiguous (given that Lua uses a
_mark_ and sweep collector) and should be cleared up in the manual.

I'm not certain I agree. This feels like an implementation detail and
formalizing it as a required behavior carries a smell to me. My
opinion is the opposite -- the documentation should be removed to
avoid asserting any sort of guarantee about the behavior, since not
every Lua implementation is going to necessarily have the same
behavior as PUC-Rio Lua.

/s/ Adam

+1 … I would assume (and I’m sure I’ll be corrected if I’m wrong) that Roberto and co would prefer to *not* provide any strong guarantees about the ordering of finalizers during a GC.

—Tim