Again. Resource deallocation in Common Lisp.

From: Lisptracker (lisptracker_at_mail.ru)
Date: 10/28/04


Date: 27 Oct 2004 15:32:49 -0700

Hi

Since the topic of resource allocation/deallocation was rised during
"Lisp vs C++" discussion I should ask here about it again.

Somebody said that the problem is solved with help of macro like
WITH-OPEN-FILE, but I didn't see solution in case when you opened file
during creation of some object and should close file immediately if
you lost all references to it in order to allow other
objects/applications to open that file.

The only thing I have thought up is to link resource holder object to
GC and assign "special free action" (finalizer) function so GC will
apply the function to the object and call proper deallocator.

Consider you have an instance which holds a slot with the AVI player
object. When you create the AVI player object it exclusively locks AVI
file. Than you assign another AVI file to this slot and the old file
will never be closed (at least until next GC). Of course I could check
slot and deallocate old resource when new resource is assigned, but
what if I've lost references to the object which holds the AVI player
(consider it was destroyed as part of another complex object) ?

So question is about deallocation of small (for GC) resources with
indefinite extent which can be shared between multiple objects in
program.

We are currently porting C++ project to Lisp (photogrammetry,
eye-tracking) and looking for analogue of destructors. May be solution
is to create something like resource managers (monitors) ?

Thanks in advance
Lisptracker



Relevant Pages

  • Re: Again. Resource deallocation in Common Lisp.
    ... > The only thing I have thought up is to link resource holder object to ... > apply the function to the object and call proper deallocator. ... When you create the AVI player object it exclusively locks AVI ... > what if I've lost references to the object which holds the AVI player ...
    (comp.lang.lisp)
  • Re: Pythons "only one way to do it" philosophy isnt good?
    ... Sure there is -- smart pointers handle many sorts of situations, ... is how non-memory resource deallocation has been dealt with in Lisp ... close files in Python. ... Lisp is also good for those things too. ...
    (comp.lang.python)
  • Re: Pythons "only one way to do it" philosophy isnt good?
    ... context manager is a superset of the RAII functionality. ... how non-memory resource deallocation has been dealt with in Lisp since ...
    (comp.lang.python)
  • Re: Pythons "only one way to do it" philosophy isnt good?
    ... >> resource deallocation. ... how non-memory resource deallocation has been dealt with in Lisp since ... close files in Python. ...
    (comp.lang.python)
  • Re: Getting URLs
    ... "Executes wget to put the search result into ... portable across Lisp systems (ok this is a Windows eecutable, ... feature behind the GET-URL function. ... It indicates the resource should be stored in this file. ...
    (comp.lang.lisp)