develooper Front page | perl.perl6.internals | Postings from May 2001

Re: Please shoot down this GC idea...

Thread Next
From:
David L. Nicol
Date:
May 2, 2001 16:14
Subject:
Re: Please shoot down this GC idea...
Message ID:
3AF09413.6ACA93EB@kasey.umkc.edu
Damien Neil wrote:
> 
>   sub foo {
>     my Dog $spot = shift;
>     my $fh = IO::File->new("file");
>     $spot->eat_homework($fh);
>   }
> 
> Even with the object type declared, the compiler can make no
> assumptions about whether a reference to $fh will be held or not.
> Perhaps the Poodle subclass of Dog will hold a reference, and the
> Bulldog subclass will not.

what if two GCs are maintained, a refcouting one for any lexical that
is a reference and is passed as a parameter, or that has a reference
taken of it and passed as a parameter, and a lexical-analysis one
for anything that is safe from these reference hazards.


 
   sub foo {
     my Dog $spot = shift;
     my $homework = shift;
     my $fh = IO::File->new($homework);	# pass=by=value, safe to LAGC
     $spot->eat_homework($fh);	# $fh is no longer fair game for LA-GC
   }





-- 
                      David Nicol 816.235.1187 dnicol@cstp.umkc.edu
                                              Parse, munge, repeat.


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About