caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@maxtal.com.au>
To: caml-list@inria.fr
Subject: Finalisers
Date: Mon, 17 Jan 2000 00:17:37 +1100	[thread overview]
Message-ID: <3881C4F1.199E96A8@maxtal.com.au> (raw)
In-Reply-To: <200001160136.MAA04210@ruby>

  Short note to David: in ocaml 2.999 [with Gc.finalise function]:
> 
> I have used Gc.finalise in Viper to implement __del__ methods.
> A short test (create an instance of a python class with a __del__
> method, then forget it)  worked correctly.

	Thoughts:

> Suppose there are two objects, A and B, with a pointer
> in A to B but not vice versa.
> Suppose A becomes globally unreachable (and suppose
> B is thereby also unreachable).
> 
> It is important to run the finaliser for A before
> the finaliser for B in this case, since the finaliser
> for A can refer to B: B is reachable from A.
> Indeed, in Python's reference counting scheme,
> this behaviour is guarranteed.
> 
> Interscript _requires_ that this ordering apply
> to finalisation. In particular, when a weaver object
> is finalised, it generates the table of contents
> of some document, the output goes to file objects.
> It is important the file objects are not finalised
> until _after_ the weaver object has generated
> the table of contents.
> 
> In general, if A and B become unreachable, and there
> is a pointer from A to B, but not from B to A,
> then the finaliser of A must be run to completion
> before the finaliser for B is invoked.
> 
> This rule cannot be applied when there is a circular dependency:
> in that case, one can consider that it would be a programming
> error on the client's part to write finalisers that depended
> on the 'other' object's unfinalised state. [Since application
> of the rule would deadlock the finalisers, and neither
> would run -- leaving garbage around]
> 
> It is NOT clear to me why interscript would core dump
> if these semantics were not provided: it would fail
> to operate correctly (generate wrong output), but not crash.

-- 
John (Max) Skaller, mailto:skaller@maxtal.com.au
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
homepage: http://www.maxtal.com.au/~skaller
download: ftp://ftp.cs.usyd.edu/au/jskaller




           reply	other threads:[~2000-01-16 21:33 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <200001160136.MAA04210@ruby>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3881C4F1.199E96A8@maxtal.com.au \
    --to=skaller@maxtal.com.au \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).