lua-users home
lua-l archive

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


> This guarantee is documented since at least Lua 5.0 [1][2]. The only
> thing that changed (and introduced the ambiguity in the manual) is
> the emphasis on "marking for finalization" instead of "object
> construction".
> Of course we could remove this guarantee, but this will make binding
> certain libraries difficult.

This is a bug in the documentation: the correct should be "in the
reverse order that they were marked for finalization".

This guarantee is not an implementation detail. (Quite the opposite,
the implementation sometimes goes to great lengths to ensure it.)
Many libraries expect this behavior and more often than not it does
the expected thing. If A was created (assuming that "marked for
finalization" is usually done just after creation) before B, it means it
can live without a B. so, it should be able to be finalized without a B,
too (that is, after any B had been finalized).  When you have cycles,
however, it is impossible to know what should be the "correct" order
without further information.

(The fact that the order is relative to "marked for finalization"
instead of "creation" is related to the implementation, though.)

-- Roberto