Skip to content

Instantly share code, notes, and snippets.

@bduggan
Created July 28, 2017 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bduggan/24e71f65de0fdf641d72a59cdb748f61 to your computer and use it in GitHub Desktop.
Save bduggan/24e71f65de0fdf641d72a59cdb748f61 to your computer and use it in GitHub Desktop.
use nqp;
my $compiler := nqp::getcomp('perl6');
my $repl = REPL.new($compiler, {});
my $save_ctx = nqp::null();
for ( '42',
'2+2',
'my $x = 2',
'$x',
'my $y:=3',
'$y' ) -> $code {
my $*MAIN_CTX;
my $*CTXSAVE = $repl;
say $repl.repl-eval: $code, my $exception, :outer_ctx($save_ctx);
$save_ctx := $*MAIN_CTX if $*MAIN_CTX;
}
# output
# 42
# 4
# 2
# 2
# 3
# (Mu)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment