[Prev][Next][Index][Thread]
Re: Destructors
----- Original Message -----
From: "Chris Double" <chris@double.co.nz>
To: <info-dylan@ai.mit.edu>
Sent: Wednesday, March 15, 2000 1:00 PM
Subject: Re: Destructors
[...]
> The safest way of ensuring construction/destruction type idioms would
> be to use block/cleanup forms I think. Wrapped in a macro like the
> with-open-file and with-lock type macros. Maybe add a resource release
> in the finalizer as well in case the user of the class does not use
> the with-* macro, or forgets to call the cleanup function. Harlequin
> Dylan does this in the SQL ODBC library for cleanup up SQL resources
> (statement handles, etc).
>
> Incidentally, I asked almost this exact question in my very first
> comp.lang.dylan post back in 1998 - finalization was the option
> presented back then too.
Finalization is a trap. It is probably the source of more questions (and
bugs) in Java than any other "feature". Your suggestion of block/cleanup is
the right way to go...
Follow-Ups:
References: