[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Exceptions (was Re: Custom extensions to Lua)
- From: David Given <dg@...>
- Date: Fri, 12 Aug 2005 14:55:06 +0100
On Friday 12 August 2005 14:08, Roberto Ierusalimschy wrote:
> I still think that we can do that with finalizers. As long as each
> object has a proper finalizer (i.e., a __gc metamethod), all we have to
> do in case of errors is to call collectgarbage() to finalize what was
I'd just like to point out that the various Java people we have here will, if
you mention finalisers to them, start frothing at the mouth and using phrases
like 'utterly brain-damaged', 'my god, what were they thinking', 'spawn of
satan' and in some circumstances 'eeeeeeeaaaaaagh'.
Just think about these:
local o = createobject()
oo = o
end -- o becomes unreachable here
-- What's oo set to now?
end -- oo becomes unreachable here
-- How many times did the finaliser get called?
call_function_that_might_yield() -- what happens here?
Of course, Java makes life much harder for itself because of the vast plethora
of different types of soft reference (there are *six* reachability states).
Lua gets away with __gc because it has very restricted functionality;
finalisers can only be written in C, the finalised objects can't be
resurrected, the finalisers can't block, etc. IMO, this is a Very Good Thing.
+- David Given --McQ-+
| email@example.com | Quidquid latine dictum sit, altum viditur.
| (firstname.lastname@example.org) |
+- www.cowlark.com --+
Description: PGP signature