[Prev][Next][Index][Thread]
Re: Object lifetime management
Brad Settlemyer <nobody@nowhere.com> writes:
> Does the dylan language offer inherent support for object lifetime
> management, or must one use a java esque approach?
Can you define a bit what you mean by object lifetime management?
Perhaps an example?
The standard method of cleaning up objects is probably a with-*
macro. Something like the standard 'with-open-file':
with-open-file(fs = "foo.txt")
do-something-with(fs);
end;
This will open and close the file 'foo.txt' within the scope of the
macro. Such macros are easy to write and often expand into the
block/cleanup construct:
let fs = #f;
block()
fs := open("foo.txt");
do-something-with(fs);
cleanup
when(fs) close(fs) end;
end;
Also available (with Functional Developer) is finalization which gives
the ability to cleanup objects when they are no longer referenced by
any other object.
Chris.
--
http://www.double.co.nz/dylan
References: