# New Ticket Created by  Aaron Sherman 
# Please include the string:  [perl #75608]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=75608 >


These two examples should behave the same:

 my $code = PAST::Compiler.compile(PAST::Block.new(PAST::Val.new(
:value(1) ))); say $code();
 my $block = PAST::Block.new(PAST::Val.new( :value(1) )); my $code =
PAST::Compiler.compile($block); say $code();

The first correctly prints "1". The second gives this error:

 get_iter() not implemented in class 'Capture'

The only difference between them is the intermediate storage in the
Rakudo variable $block, which implies that either
PAST::Compiler.compile cannot handle a rakudofied PAST::Block value or
the storage of PAST::Block into $block alters its value irrevocably.
Either way, this would appear to be a bug, and prevents any attempt to
generate new code from within Rakduo without dropping down to a Q:PIR,
and even then I'm not certain. All of this works fine in the
bootstrapped compiler, of course, but in that case, NQP aliases these
variables rather than letting Rakudo get its grubby little mitts all
over them ;-)

The relevant conversation from IRC:

(10:18:39 AM) ajs: rakudo: my $code =
PAST::Compiler.compile(PAST::Block.new(PAST::Val.new( :value(1) )));
say $code();
(10:18:42 AM) p6eval: rakudo 34c1ba: OUTPUT«1␤»
(10:19:31 AM) ajs: rakudo: my $block = PAST::Block.new(PAST::Val.new(
:value(1) )); my $code = PAST::Compiler.compile($block); say $code();
(10:19:33 AM) p6eval: rakudo 34c1ba: OUTPUT«get_iter() not implemented
in class 'Capture'␤ in main program body at line 11:/tmp/Gcz_AAWNc_␤»
(10:19:45 AM) ajs: Anyone know why those two aren't the same?
(10:20:47 AM) jnthn: rakudo: rakudo: my $block =
PAST::Block.new(PAST::Val.new( :value(1) )); say "alive"
(10:20:49 AM) p6eval: rakudo 34c1ba: OUTPUT«===SORRY!===␤Confused at
line 11, near "rakudo: my"␤»
(10:21:00 AM) jnthn: rakudo: my $block =
PAST::Block.new(PAST::Val.new( :value(1) )); say "alive"
(10:21:04 AM) p6eval: rakudo 34c1ba: OUTPUT«alive␤»
(10:21:18 AM) pmichaud: PAST compiler might not know what to do with
rakudo objectrefs
(10:21:18 AM) jnthn: rakudo: my $block =
PAST::Block.new(PAST::Val.new( :value(1) )); my $code =
PAST::Compiler.compile($block);
(10:21:20 AM) p6eval: rakudo 34c1ba: OUTPUT«get_iter() not implemented
in class 'Capture'␤ in main program body at line 11:/tmp/sXHbFObB83␤»
(10:21:42 AM) jnthn: pmichaud: Oh, oddness. I'd have thought they'd be
transparent to it.
(10:21:59 AM) pmichaud: well, so would I, but normally we're doing
binding instead of assignment in NQP
(10:22:04 AM) jnthn: True.
(10:22:18 AM) ajs: Yeah, and sadly that's not an option in Rakudo
(10:22:30 AM) masak: submit a rakudobug?
(10:22:32 AM) pmichaud: rakudo: my $block =
PAST::Block.new(PAST::Val.new( :value(1) )); say PARROT($block)
(10:22:35 AM) p6eval: rakudo 34c1ba: OUTPUT«Perl6Scalar->PAST;Block␤»
(10:22:49 AM) ajs: Fair enough, just wanted to be sure I wasn't doing
something stupid
(10:23:17 AM) ajs: Hmmm pmichaud, you might be onto something there,
let me try that out
(10:23:19 AM) pmichaud: it may also be that PAST::Compiler isn't
returning something that rakudo knows how to process
(10:23:35 AM) jnthn: pmichaud: That worked in the pervious example though.
(10:23:36 AM) ajs: It works fine in the first case
(10:23:47 AM) pmichaud: oh, good point.
(10:23:54 AM) jnthn: uh, previous :-)
(10:23:57 AM) pmichaud: so I fall back to "there's something weird about $block"
(10:24:43 AM) pmichaud: yes, I would expect it to be transparent...
but perhaps it isn't for some reason.
(10:24:53 AM) ajs: rakudo: my $block = PAST::Block.new(PAST::Val.new(
:value(1) )); my $code = PAST::Compiler.compile(PARROT($block)); say
$code();
(10:24:55 AM) p6eval: rakudo 34c1ba: OUTPUT«Null PMC access in type()␤
in main program body at line 11:/tmp/cgP_Wd5cmw␤»
(10:25:07 AM) ajs: OK, will go the bug route. Thanks all.
(10:25:19 AM) pmichaud: yes, I'd be curious as to what that could possibly be.
(10:26:01 AM) pmichaud: I'm also curious as to whether the get_iter is
failing on a Parrot Capture or a Rakudo Capture
(10:26:44 AM) jnthn: The latter would be very odd.
(10:27:00 AM) pmichaud: agreed... but it's all a little odd to begin with
(10:27:06 AM) jnthn: (Since we inherit from Parrot Capture...)
(10:27:09 AM) jnthn: Troo. :-)

--
Aaron Sherman
Email or GTalk: a...@ajs.com
http://www.ajs.com/~ajs

Reply via email to