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

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

Thread Previous | Thread Next
February 14, 2001 11:12
Re: Garbage collection (was Re: JWZ on s/Java/Perl/)
Message ID:
On Wed, Feb 14, 2001 at 01:30:03PM -0300, Branden wrote:
> John Porter wrote:
> > James Mastros wrote:
> > > I'd think that an extension to delete is in order here.  Basicly, delete
> > > should DESTROY the arg, change it's value to undef,...
> >
> > Huh?  What delete are you thinking of?  This is Perl, not C++.
> >
> Agreed, definitely Perl is not C++.
> > > ...and trigger a GC that will get rid of the arg.
> >
> > No.  Perl decides for itself when to do GC.
> >
> Please read the original message I wrote. The reply had only some
> off-the-context snippets of the original idea.
> The idea is to *allow* a programmer to explicitly destroy an object, for
> better (and sooner) resource disposal. The programmer wouldn't have to do it
> (and wouldn't do it most the time), but if he knows he uses many resources
> and he would like to be nice, he *could* do it (not meaning he would have to
> do it either...).

There is no need to add that to Perl, as Perl already has a function
for that: C<undef $obj;>.

Naturally, that won't cause DESTROY to be run if there are other
references to it, but then, I don't see what an "object destruction"
is supposed to do if there are still references to the object left.
Nor is this wanted behaviour. All the programmer needs to do for
sooner resource disposal it to let his references go out of scope
when no longer needed.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About