At 03:38 PM 12/6/00 -0500, Sam Tregar wrote:
>On Wed, 6 Dec 2000, Dan Sugalski wrote:
>
> > >    my $new_dog;
> > >    {
> > >       my $dog = new Dog;
> > >       $new_dog = \$dog;
> > >    }
> >
> > That would hoist the Dog reference into an outer level of scope--in this
> > case the one containing $new_dog. Or so my thinking goes at the moment,
> > though there may be (almost inevitably are) problems with that.
>
>"hoist"?  I thought this was a stack you were talking about.  You're going
>to do an O(n) operation on a stack every time a reference is passed out of
>scope?  What happens when two references diverge:

There are ways around that--the destruct stack could have a level of 
indirection in it, though that's getting rather more complex than I'd like.

>    my $newDog1;
>    {
>      my $newDog2;
>         {
>            my $dog = new Dog;
>            $newDog2 = $newDog1 = \$dog;
>         }
>      $newDog1 = undef;
>     }
>
>How does a non-refcounting scheme know that $newDog2 is the last ref to
>$dog when the first block is done?

Hmmm. Okay, bad plan. I don't have a Plan B, though. We may want a 
refcounting scheme for destructed objects, or variables that get referenced.

>As far as claims about mark-and-sweep improving performance, I guess we'd
>need a test implementation in order to find out.  Considering the
>non-deterministic character of many mark-and-sweep systems performance
>testing can be a delicate matter.

All I have to go on is the literature, so this is somewhat shaky, but... 
Non-refcounting GC schemes are more expensive when they collect, but less 
expensive otherwise, and it apparently is a win for the non-refcount 
schemes. There are techniques to spread the GC cost around as well, so 
there aren't huge freezes when it comes time to collect the heap. If perl 
takes a more active stance with it's trash as well (where blocks can 
immediately toss variables that are guaranteed to be trash) we may also be 
able to lower the impact of GC.

                                        Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to