[gclist] Re: buffer example

fjh@cs.mu.OZ.AU fjh@cs.mu.OZ.AU
Thu, 14 Mar 1996 15:34:25 +1100 (EDT)


David Petrie Stoutamire, you wrote:
> 
> Fergus, if you are reading this, what does Mercury say about
> finalization and unique modes?

Basically nothing.  Mercury doesn't support automatic finalization,
except via the C interface.  The C interface gives access to
the Boehm collector's finalization operations.

At first glance it seems that finalization operations with visible
side effects would be somewhat of an anathema to the Mercury
computation model, since they would break referential transparency.
(I suppose it might be possible to devise a clever semantic
model that allows them and still preserves referential transparency,
so I wouldn't rule out the possibility that Mercury might support them
in the future.)

Automatic finalization could be useful in Mercury for managing
non-memory OS resources such as file handles, where the finalizers
could be considered to have no visible side effect (possibly sweeping
some issues under the carpet...).  But since access to such resources
will be done via the C interface (or conceivably via the assembler
interface), there doesn't seem to be any advantage to supporting
finalization directly as part of the Mercury language.

Unique modes allow the compiler to perform "compile-time garbage
collection" by inserting calls to explicit deallocation primitives such
as GC_free() in the Boehm collector.  So unique modes could be used to
guarantee immediate finalization (of objects representing OS resources,
which have had finalizers registered via the C interface).  However, we
still haven't implemented compile-time garbage collection yet.

-- 
Fergus Henderson             	WWW: http://www.cs.mu.oz.au/~fjh
fjh@cs.mu.oz.au              	PGP: finger fjh@128.250.37.3
"No Bad Religion song can make your life complete" -- Bad Religion.