In Independent routines§

See primary documentation in context for sub repl

Note: repl was introduced in release 2021.06 of the Rakudo compiler.

sub repl()

Pauses execution and enters a REPL (read-eval-print loop) in the current context. This REPL is exactly like the one created when you run raku without any arguments except that you can access/modify the program's current context (such as lexical variables).

For example, if you run this code:

my $name = "Alice";
 
say "Hello, $name";
 
repl();
 
say "Goodbye, $name"

then you'll get the output Hello, Alice and then enter a REPL session (before any output with "goodbye" is printed). Your REPL session could go as follows:

Type 'exit' to leave
[0] > $name
Alice
[1] > $name = "Bob"
Bob
[2] > exit

After exiting the REPL session, Raku will resume running the program; during this run, any changes you made in the REPL session will still be in effect. Thus, after the session above, you'd get the output Goodbye, Bob rather than Goodbye, Alice as you would have without the REPL session.