At 06:47 AM 12/6/00 -0800, Evan Howarth wrote:
>Perhaps a hybrid approach would solve all the language needs. Retain
>reference counting. When the count drops to zero, call the destructor and
>mark the object. Free marked objects when sweep runs. To reclaim circular
>references, the sweep task may periodically scan the stack, globals, etc.
>The scan would find circular references and set their counts to zero.
>Because circular references are rare, the scan need not occur every time a
>sweep is performed. This example shows that you can offend all "religious"
>camps and still capitalize on their disparate arguments.
I'm looking to completely decouple destruction and garbage collection in
perl 6. Garbage collection's really an internal thing, something that a
perl programmer shouldn't need to worry about. It's housekeeping, and
that's what perl's supposed to do automagically.
What I'm thinking is that we'll have a scoped destruct stack that gets
pointers to variables that explicitly need destruction, and as we exit
levels of scope we call the destructors of those variables that need it.
(They can still be GC'd later to pick up their now-free memory) Most things
won't get tossed on there, since most variables don't have any destruction
behaviour.
This will hopefully be a performance win in some cases, since most of the
reference works I've got indicate that reference counting GC is the most
expensive, as you spend a lot of CPU time twiddling the ref count. (Though
I do know that a number of the GC implementations get around this somewhat)
Decoupling GC and destruction also means we can change the GC when we think
it's necessary--it may turn out that our initial choice is sub-optimal, and
switching to another later buys us some performance, and that's keen too.
(It also means we can start with a relatively naive GC, say a simple mark
and sweep, or copying collector, and tune it later once everything else is
working)
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk