[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GScheme on Mac OS X/Darwin
From: |
Marko Riedel |
Subject: |
Re: GScheme on Mac OS X/Darwin |
Date: |
Tue, 6 Aug 2002 14:07:58 +0200 (CEST) |
Markus Hitter writes:
>
> Am Montag den, 5. August 2002, um 15:19, schrieb Marko Riedel:
>
> > b) empty an array without the contents getting a release message
>
> Can't imagine a situation where this would be good design. Would
> you want to avoid the -retain when the objects are added to the
> array, too? Why?
>
> It's easy however: send every object a -retain before releasing
> the array.
>
>
> Markus
>
> - - - - - - - - - - - - - - - - - - -
> Dipl. Ing. Markus Hitter
> http://www.jump-ing.de/
>
>
Hi there,
Scheme data structures are highly circular. Here are two examples:
* someone enters a list and uses set-cdr! to set the cdr of the last
pair to point to the beginning of the list
* someone makes a closure, which contains a pointer to the current
environment; this environment contains a chain of frames which
eventually lead to the global environment, where some variable is
bound to the closure in question, which contains a pointer etc. etc.
Retain/release only works if your objects form a tree, or rather, if
your object graph can reliably be mapped onto a tree. The Cocoa docs
suggest that one make a decision as to the direction of the arcs in
the object graph. This is not possible with circular lists, however.
I wrote my own garbage collector for this reason. It can happen that
it deallocates an object in a dictionary or array before it
deallocates the dictionary/array itself. Deallocation for the entries
is taken care of by my GC.
Thanks for the suggestions anyway. I'll think about this some
more. BTW I tried deallocating environments before all other objects
but somehow I couldn't get it to work.
Best regards,
--
+------------------------------------------------------------+
| Marko Riedel, EDV Neue Arbeit gGmbH, mriedel@neuearbeit.de |
| http://www.geocities.com/markoriedelde/index.html |
+------------------------------------------------------------+