Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > e3d62627d1d1aab7ab1be2dd7f65a872 > files > 276

ecl-10.4.1-1.fc14.x86_64.rpm

<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>5.5.&#160;Finalization</title><link rel="stylesheet" href="ecl.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"><link rel="home" href="index.html" title="The ECL manual"><link rel="up" href="ch20.html" title="Chapter&#160;5.&#160;Memory Management"><link rel="prev" href="ch20s04.html" title="5.4.&#160;Memory Conditions"><link rel="next" href="ch20s06.html" title="5.6.&#160;Memory Management Reference"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">5.5.&#160;Finalization</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch20s04.html">Prev</a>&#160;</td><th width="60%" align="center">Chapter&#160;5.&#160;Memory Management</th><td width="20%" align="right">&#160;<a accesskey="n" href="ch20s06.html">Next</a></td></tr></table><hr></div><div class="section" title="5.5.&#160;Finalization"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="ext.memory.finalization"></a>5.5.&#160;Finalization</h2></div></div></div><p>As we all know, Common-Lisp relies on garbage collection for deleting
   unreachable objects. However, it makes no provision for the equivalent of a
   C++ Destructor function that should be called when the object is eliminated
   by the garbage collector. The equivalent of such methods in a garbage
   collected environment is normally called a <span class="emphasis"><em>finalizer</em></span>.</p><p><span class="application">ECL</span> includes a simple implementation of finalizers which makes the
   following promises.</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>The finalizer can be any lisp function, let it be compiled
    or interpreter.</p></li><li class="listitem"><p>Finalizers are not invoked during garbage
    collection. Instead, if an unreachable object is found to have an
    associated finalizer, it is pushed into a list and <span class="emphasis"><em>before the
    next garbage collection cycle</em></span>, the finalizer will be
    invoked. </p></li><li class="listitem"><p>If the finalizer is invoked and it makes the object
    reachable, for instance, by assigning it to a variable, it will not be
    destroyed, but it will have no longer a finalizer associated to
    it.</p></li><li class="listitem"><p><span class="application">ECL</span> will strive to call finalizers before the environment
    is closed and the program is finished, but this mechanism may fail when
    exiting in a non ordinary way.</p></li></ul></div><p>The implementation is based on two functions, <a class="xref" href="re33.html" title="ext:set-finalizer"><code class="function">ext:set-finalizer</code></a> and <a class="xref" href="re31.html" title="ext:get-finalizer"><code class="function">ext:get-finalizer</code></a>, which allow setting and querying the
   finalizer functions for certain objects.</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch20s04.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="ch20.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="ch20s06.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">5.4.&#160;Memory Conditions&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;5.6.&#160;Memory Management Reference</td></tr></table></div></body></html>