On Fri, Oct 05, 2007 at 03:12:07AM -0500, Patrick R. Michaud wrote:
> In pdd15oo, there seems to be an issue about using load_bytecode
> to load :method subs after a class has been created.

The :method pragma also seems to not work for code that is 
compiled using the built-in PIR compiler.  Here's another test 
case:

----------
$ cat z.pir
.sub 'main' :main
    $P0 = newclass 'Foo'
    $P1 = new 'Foo'
    $P1.'foo_method'()

    $S2 = <<'END'
        .namespace ['Foo']
        .sub 'bar_method' :method
            say 'bar_method'
        .end
END
    $P2 = compreg 'PIR'
    $P2($S2)

    $P1 = new 'Foo'
    $P1.'bar_method'()
.end


.namespace ['Foo']

.sub 'foo_method' :method
    say 'foo_method'
.end


$ ./parrot z.pir
foo_method
Method 'bar_method' not found
current instr.: 'main' pc 35 (z.pir:16)
$
----------


Unfortunately this bug is blocking quite a few PGE-related tools
(or other components that make use of the PGE-related tools).

Since placing a sub in a namespace no longer automatically enables
it as a method, PGE has had to decorate all of its dynamically
generated regex subs with :method pragmas (and change the arguments
accordingly).  But since :method isn't always causing the sub to
be registered as a method, we're a bit stuck.

(PGE *could* generate :load/:init subs to dynamically call add_method
on the class for each sub whenever the code is loaded, but it seems like
PIR ought to be able to handle this automatically.)

Pm

Reply via email to