[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: gc fallback
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 09 Jun 1997 14:24:35 -0300
Dear Alan,
The program you presented have two little bugs:
> function gc(table)
> if table[nil] then end
> end
> setfallback("gc", gc)
1) you cannot index a table with nil: this causes an error.
1) the gc fallback is called with 'nil' when the gc ends, so you will have
an error even with a different index, since "table" will be nil.
Nevertheless, *there are* some problems with this fallback. If by any
chance the code inside it creates a new object (a string or a table)
the gc is called again, creating the loop you mentioned. This is written
in the manual, but it doesn't help, since it is very difficult
to be sure whether a piece of code creates new objects. That restriction
is fixed in Lua 3.0 beta, that should be available in 2~3 weeks, at most. (The
implementation is done, but we have to update the manual and do some extra
tests, mainly for performance.)
-- Roberto