REPL

Read-eval-print loop

Overview

The REPL is an interactive Raku prompt. Each line of code you enter in the REPL is executed, and if no output was generated, the value returned by the expression is output.

Trap

Note: Running code in the REPL is not equivalent to saving the code in a file and running that. Each line introduces a new scope which can confuse code that has multiple lines. See sub repl() below for a way to target a REPL inside a larger script.

non-interactive mode

If invoked from the command line with raku --repl-mode=non-interactive, no history or prompts are printed, and the code is not executed until you close input (on Linux, for example, you can pipe the code to it or press Control-d.

    $ echo "say 3" | raku --repl-mode=non-interactive
    3

sub repl()

This routine allows you to embed a REPL inside a larger script and have access to all the variables in context.

See sub repl() in Independent Routines for more information.

ENVIRONMENT Variables

See ENVIRONMENT Variables.

Get command line history

In a fresh install, there is no command history. Running the REPL in this mode will prompt you to install one of the various modules that provide this support. If enabled, you can use the arrow keys to scroll through previous commands and use standard terminal shortcuts for editing. There are currently four options:

  • 1

    zef install Terminal::LineEditor
  • 2

    zef install Linenoise

This requires a working C toolchain.

  • 3

    zef install Readline

This requires an installation of the Readline development library.

  • 4

An alternative for UNIX-like systems is to install rlwrap. This can be done on Debian-ish systems by running:

sudo apt-get install rlwrap

And then use it to invoke the REPL:

rlwrap raku

See Also

Classes and objects

A tutorial about creating and using classes in Raku

CompUnits and where to find them

How and when Raku modules are compiled, where they are stored, and how to access them in compiled form.

Concurrency

Concurrency and asynchronous programming

Command line interface

Creating your own CLI in Raku

Grammar tutorial

An introduction to grammars

Input/Output

File-related operations

Inter-process communication

Programs running other programs and communicating with them

Iterating

Functionalities available for visiting all items in a complex data structure

Doing math with Raku

Different mathematical paradigms and how they are implemented in this language

Module packages

Creating module packages for code reuse

Core modules

Core modules that may be useful to module authors

Module development utilities

What can help you write/test/improve your module(s)

Modules

How to create, use, and distribute Raku modules

Creating operators

A short tutorial on how to declare operators and create new ones.

Regexes: best practices and gotchas

Some tips on regexes and grammars

Entering unicode characters

Input methods for unicode characters in terminals, the shell, and editors

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.