develooper Front page | perl.perl6.language | Postings from February 2001

Re: Garbage collection (was Re: JWZ on s/Java/Perl/)

Dan Sugalski
February 12, 2001 14:35
Re: Garbage collection (was Re: JWZ on s/Java/Perl/)
Message ID:
At 11:28 PM 2/12/2001 +0100, Robin Berjon wrote:
>At 15:37 12/02/2001 -0500, Dan Sugalski wrote:
> >It *is* rare in OO perl, though. How many of the variables you use are
> >really, truly in need of finalization? .1 percent? .01 percent? Less? Don't
> >forget that you need to count every scalar in every array or hash, and
> >every iteration over a block with my declarations. Perl churns through a
> >*lot* of SV pointers in its average run, and most of them aren't in need of
> >finalization.
>Couldn't we simply (for non-implementer values of simply) provide a way for
>people to ask for finalization on an object ? Given that most of the time
>it isn't needed, it wouldn't be too much of a burden for programmers to
>have to write i_want_some_finalization($object, [finalization params]) ?

Sure. Y'know, maybe we could even have a sub with a special name! Maybe... 

Seriously, I presume Larry will want perl 6 to follow perl 5's lead and use 
the DESTROY sub to indicate that an object should be actively (rather than 
passively) trashed when the interpreter is sure the object is unused. 
Adding something like:

   package foo;
   use attrs qw(cleanup_sub);

would be nice, but I don't know that he'll go for it. (Though it's the only 
way I can think of to avoid AUTOLOAD being considered a potential destructor)


--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai                         have teddy bears and even
                                      teddy bears get drunk Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About