Re: pdd15oo: load_bytecode and :method subs

2007-10-06 Thread Allison Randal
Allison Randal wrote: 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. Working now for both load_bytecode and the eval case. One problem: with this change, every named method is inserted into the

pdd15oo: load_bytecode and :method subs

2007-10-05 Thread Patrick R. Michaud
In pdd15oo, there seems to be an issue about using load_bytecode to load :method subs after a class has been created. Here's my test code. The main file is 'foo.pir': $ cat foo.pir .sub 'main' :main $P0 = newclass 'Foo' $P1 = new 'Foo' $P1.'foo_method'()

Re: pdd15oo: load_bytecode and :method subs

2007-10-05 Thread Patrick R. Michaud
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

Re: pdd15oo: load_bytecode and :method subs

2007-10-05 Thread Allison Randal
It's a timing issue. Methods are currently loaded into the class from the namespace when the class is created. So, if you call load_bytecode after newclass, it helpfully inserts the methods into the namespace, but the class doesn't pick them up. (This has been on my radar for a while, I just

Re: pdd15oo: load_bytecode and :method subs

2007-10-05 Thread Patrick R. Michaud
On Fri, Oct 05, 2007 at 10:30:03AM -0700, Allison Randal wrote: I'll work on this today, but if you want the quick fix, just call load_bytecode before newclass. (The quick fix won't work for your eval example.) This is the workaround I'm using to get the PGE tests to pass, but it's not

Re: pdd15oo: load_bytecode and :method subs

2007-10-05 Thread Allison Randal
Patrick R. Michaud wrote: At any rate, pgc.pir and Perl6Grammar.pir (used to compile grammars into PIR) both want the ability to compile and install rules at runtime, so we really need the eval version to work before we can progress much. Either that or I'll come up with a workaround for

Re: pdd15oo: load_bytecode and :method subs

2007-10-05 Thread chromatic
On Friday 05 October 2007 11:55:21 Patrick R. Michaud wrote: In the case of dynamically generated code, using add_method is somewhat more challenging because we can't perform the add_method until after the PIR source has been compiled and loaded into the namespace. That means that in

Re: pdd15oo: load_bytecode and :method subs

2007-10-05 Thread Allison Randal
Patrick R. Michaud wrote: In the case of dynamically generated code, using add_method is somewhat more challenging because we can't perform the add_method until after the PIR source has been compiled and loaded into the namespace. Aye. There's a dividing line that's more a matter of style

Re: pdd15oo: load_bytecode and :method subs

2007-10-05 Thread Patrick R. Michaud
On Fri, Oct 05, 2007 at 11:05:50AM -0700, Allison Randal wrote: Patrick R. Michaud wrote: At any rate, pgc.pir and Perl6Grammar.pir (used to compile grammars into PIR) both want the ability to compile and install rules at runtime, so we really need the eval version to work before we can

Re: pdd15oo: load_bytecode and :method subs

2007-10-05 Thread Patrick R. Michaud
On Fri, Oct 05, 2007 at 12:08:03PM -0700, Allison Randal wrote: Patrick R. Michaud wrote: In the case of dynamically generated code, using add_method is somewhat more challenging because we can't perform the add_method until after the PIR source has been compiled and loaded into the

Re: pdd15oo: load_bytecode and :method subs

2007-10-05 Thread Allison Randal
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. Working now for both load_bytecode and the eval case. Turns out to be very few lines of code to make it work. I also added Patrick's examples as