Reussir Language Reference

RREPL: Interactive Reussir

RREPL: Interactive Reussir

rreplrrepl is the fastest place to try a Reussir expression. It elaborates each input, compiles it with the JIT, prints the value and its type, and keeps definitions available for the rest of the session. No package or manifest is needed.

1. Start a session

Run:

rrepl
rrepl

On a capable interactive terminal, rreplrrepl opens its terminal UI. The same commands are also available in a simple line-oriented prompt, which is useful inside terminal multiplexers and when recording a session:

rrepl --no-tui
rrepl --no-tui

Enter an expression at the λ>λ> prompt:

λ> 1 + 1
2 : i64
λ> 1 + 1
2 : i64

The text after the colon is the inferred result type.

2. Define and call a function

Definitions remain in the session, so a function can be entered and used immediately:

λ> fn double(x: i32) -> i32 { x + x }
Definition added.
λ> double(21)
42 : i32
λ> fn double(x: i32) -> i32 { x + x }
Definition added.
λ> double(21)
42 : i32

This is normal Reussir source—the prompt is the only part that would not appear in a .rr.rr file.

3. Enter a multiline definition

In the plain prompt, put :{:{ on its own line to begin a multiline input and }:}: on its own line to submit it:

λ> :{
| fn fact(n: u64) -> u64 {
| if n == 0 { 1 } else { n * fact(n - 1) }
| }
| }:
Definition added.
λ> :{
| fn fact(n: u64) -> u64 {
| if n == 0 { 1 } else { n * fact(n - 1) }
| }
| }:
Definition added.

Now call the function and ask for the type of an expression without evaluating it:

λ> fact(10)
3628800 : u64
λ> :type fact(3)
fact(3) : u64
λ> fact(10)
3628800 : u64
λ> :type fact(3)
fact(3) : u64
An interactive Reussir session evaluating arithmetic, defining double and factorial functions, and inspecting a type.
Expressions, persistent definitions, multiline input, and type inspection in one session.

In the full terminal UI, Enter submits complete input and inserts another line while the input is incomplete; Alt+Enter always inserts a newline. The explicit :{:{ and }:}: form works in both frontends and in recorded scripts.

4. Inspect or reset the session

Type :help:help for the complete command list. The commands used most often while exploring are:

  • :type EXPR:type EXPR elaborates an expression and reports its type without running it;
  • :dump context:dump context prints the accumulated definitions as HIR;
  • :dump compiled:dump compiled lists functions emitted by the JIT;
  • :dump bindings:dump bindings shows global letlet bindings and their current values;
  • :set opt LEVEL:set opt LEVEL changes the JIT optimization level for later inputs;
  • :clear:clear discards definitions and compiled code;
  • :q:q or :quit:quit exits.

The available optimization levels are nonenone, defaultdefault, aggressiveaggressive, sizesize, and tpdetpde. The default uses TPDE when that backend was included in the build, favoring short compile latency for an interactive session.

5. Replay a session from a file

For a repeatable experiment, place definitions, expressions, and colon commands in a text file—for example, experiment.replexperiment.repl—and run it line by line:

rrepl -i experiment.repl -l error
rrepl -i experiment.repl -l error

Script mode uses the plain frontend automatically. It is a convenient bridge between a quick interactive idea and the src/lib.rrsrc/lib.rr of a Rene project.