On Thu, Oct 27, 2005 at 05:28:36PM +0200, Leopold Toetsch wrote:
> Patrick R.Michaud (via RT) wrote:
> 
> >.sub main :main
> >    $P0 = open "sf8-sub.pir", "<"
> >    $S0 = read $P0, 65535
> >
> >    $P1 = compreg "PIR"
> >    $P1($S0)
> 
> The return result of the compilation (an Eval PMC) isn't stored anywhere 
> and get's GCed. This also kills the compiled subroutine.
> 
>     $P2 = $P1($S0)
>     register $P2        # or store_global ...
> 
> This is maybe not the correct way to deal with compiled code, OTOH: 
> Parrot doesn't know anything about the planned life-time of the compiled 
> code and keeping it alive by default might be as undesriable.

FWIW, I think the "natural" expectation is that a compiled sub (and its
associated Eval PMC) will both remain alive through the global symbol 
table entry until it's released -- either by removing the symbol table
entry or replacing it with a different PMC.

If a compiled sub is marked :anon, then it doesn't create an entry in
the global symbol table and is therefore GCed as normal -- generally
around the time the Eval PMC gets GCed (i.e., when there are no more
live references to the Eval PMC).

But now that I know what is happening, I can work with whatever
gets decided.

Many thanks for the quick fixes,

Pm

Reply via email to