The Revenge of Finalizers
Malcolm.Wallace at cs.york.ac.uk
Mon Oct 21 11:08:35 EDT 2002
Alastair Reid <alastair at reid-consulting-uk.ltd.uk> writes:
> > Do we /want/ a blackhole?
> A blackhole would be wrong semantically because:
> - blackholes mean that a value depends on itself - that isn't true here
Agreed. The usual operational discovery of a blackhole in a
non-threaded system is exactly when the mutator is attempting to
evaluate a node that is already under evaluation. Since the finaliser
is essentially a separate thread, that simple operational understanding
no longer points definitively to a blackhole.
> - changing evaluation order shouldn't change whether the program
> produces an answer or what answer it produces
Apart from possibly changing the order of any side-effects, yes.
> btw What abstract machine is NHC based on? Given its Swedish origins,
> I expect it's a slightly modified G machine?
Exactly so. The paper "nhc - a space-efficient Haskell compiler"
in Niklas's thesis (also presented at IFL94, ICFP95) mentions that
it is a very basic G machine, based on the SimonPJ implementation
book (1987). Since then, we've made a few tweaks for performance,
but no major changes to the model.
> The problem is that the G-machine
> optimizes away some of the updates which make sure that the heap is
> always in a consistent state in a pure graph-reduction system.
A pure G-machine updates all redexes, but the STG-machine only updates
/shared/ redexes, yes?
More information about the FFI