Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Perlito5 - perl6-eval.p6: add notes
  • Loading branch information
fglock committed May 26, 2012
1 parent 1eb7e0c commit ae3f389
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions perl6-eval.p6
Expand Up @@ -23,28 +23,30 @@ eval($p5_str, :lang<perl5>);
=begin comments
If I define multi eval($str, :$lang! where 'perl5')
then rakudo can't find eval :lang<perl6> anymore
because eval is declared as an only sub
This is a workaround (by moritz++):
proto eval(|$) {*};
multi sub eval($str) {
$str.eval;
}
Accessing perl6 variables inside eval (explained by moritz++):
sub f { say OUTER::.keys }; { my $x = 3; f() }
# $! GLOBALish $=pod EXPORT !UNIT_MARKER $?PACKAGE ::?PACKAGE $_ &f $/
sub f { say CALLER::.keys }; { my $x = 3; f() }
# call_sig $x $_ $*DISPATCHER
and you might need to walk the CALLER's OUTER
this one just gives you the immediate caller's scope
Note: fixed in rakudo commit e756635b9e:
If I define multi eval($str, :$lang! where 'perl5')
then rakudo can't find eval :lang<perl6> anymore
because eval is declared as an only sub
This is a workaround (by moritz++):
proto eval(|$) {*};
multi sub eval($str) {
$str.eval;
}
Note: Accessing perl6 variables inside eval (explained by moritz++):
sub f { say OUTER::.keys }; { my $x = 3; f() }
# $! GLOBALish $=pod EXPORT !UNIT_MARKER $?PACKAGE ::?PACKAGE $_ &f $/
sub f { say CALLER::.keys }; { my $x = 3; f() }
# call_sig $x $_ $*DISPATCHER
and you might need to walk the CALLER's OUTER
this one just gives you the immediate caller's scope
=end comments
Expand Down

0 comments on commit ae3f389

Please sign in to comment.