lua-users home
lua-l archive

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


> "Lins's algorithm is lazy in the sense that the mark-sweep garbage
> collection is performed on demand.  [...big snip...]  Like
> generational garbage collection, Lins's method works best when
> side-effects are comparatively rare, for example for programs written
> in a functional style.  Its success also rests on the assumptions that
> the great majority of nodes are uniquely referenced and can be
> reclaimed without resort to garbage collection; and that the
> sub-graphs traversed are sufficiently small to make the garbage
> collection delay small.

Most of these are not true in Lua: most programs use mainly side-effects
to do their jobs, and many nodes have more than one reference (because a
single assignment or parameter passing duplicates the reference). Maybe
that's why I forgot about it ;-)

In a related subject: I don't want to go into the merits of reference
counting x games, but I feel that a correct implementation of reference
counting in Lua is not going to be simple. For instance, everytime Lua
pops its stack (a simple "L->top--", for instance) it is destroying
references. The stack is pervasive in Lua's implementation, and to
control correctly all these pushs and pops seems a difficult task. (More
difficult yet if there is any concern with performance...)

-- Roberto