REPL Guide¶
Launch the interactive REPL with no arguments:
Line Editing¶
The REPL uses linenoise for line editing with full terminal support.
| Key | Action |
|---|---|
| Left / Right | Move cursor |
| Up / Down | Navigate history |
| Ctrl+A | Move to start of line |
| Ctrl+E | Move to end of line |
| Ctrl+K | Delete from cursor to end |
| Ctrl+U | Delete entire line |
| Ctrl+W | Delete previous word |
| Ctrl+L | Clear screen |
| Ctrl+D | Delete char at cursor (or exit if line empty) |
| Ctrl+T | Transpose characters |
| Tab | Auto-complete symbol names |
| Ctrl+R | Reverse history search |
| Ctrl+C | Cancel current line |
Tab Completion¶
Press Tab to complete symbol names from the global environment:
Completion matches all bound symbols — built-in procedures, your own definitions, and imported library exports.
History¶
History is saved automatically to .kaappi_history in the current directory. Up to 1000 entries are preserved across sessions.
- Up / Down arrows — navigate through previous entries
- Ctrl+P / Ctrl+N — same as Up / Down
Reverse History Search (Ctrl+R)¶
Press Ctrl+R to incrementally search through history, just like bash:
Type a search query — matching history entries appear as you type:
| Key | Action |
|---|---|
| Type characters | Refine search |
| Ctrl+R | Jump to next (older) match |
| Enter | Accept the match for editing |
| Escape | Cancel and restore original line |
| Backspace | Remove last search character |
Multi-line Input¶
Expressions with unmatched parentheses automatically continue on the next line:
The prompt changes to ... while input is incomplete. Press Ctrl+C to cancel a multi-line entry.
The _ Variable¶
The special variable _ always holds the result of the last evaluation:
kaappi> (* 6 7)
42
kaappi> (+ _ 8)
50
kaappi> (string-append "answer: " (number->string _))
"answer: 50"
This is useful for exploratory programming — evaluate something, then use the result without re-typing or binding it.
REPL Commands¶
All commands start with a comma (,). They are not Scheme expressions.
Inspection¶
,type <expr> — Show result type¶
kaappi> ,type (+ 1 2)
; integer
kaappi> ,type "hello"
; string
kaappi> ,type (list 1 2 3)
; pair
kaappi> ,type car
; procedure
kaappi> ,type #t
; boolean
,describe <symbol> — Show binding details¶
Shows the type, arity, and source location of a procedure:
kaappi> ,describe car
car
type: procedure
arity: 1
kaappi> ,describe map
map
type: procedure
arity: 2+
kaappi> ,describe +
+
type: procedure
arity: 0+
For user-defined procedures, it also shows the source file and line:
kaappi> (define (greet name) (string-append "Hello, " name))
kaappi> ,describe greet
greet
type: procedure
arity: 1, locals: 0
source: <repl>:1
,apropos <string> — Search bindings¶
Searches all global bindings for names containing the given substring:
kaappi> ,apropos vector
vector-append
vector-copy
vector-fill!
vector-for-each
vector-length
vector-map
vector-ref
vector-set!
vector?
list->vector
vector->list
make-vector
...
; 18 matches
,env [prefix] — List bindings¶
Lists all global bindings, optionally filtered by prefix:
Timing and Profiling¶
,time <expr> — Measure execution time¶
,profile <expr> — Detailed profiling¶
Shows per-function timing, call counts, and memory allocations:
Macros¶
,expand <expr> — Show macro expansion¶
Debugging¶
,break <name> — Set breakpoint¶
,breakpoints — List breakpoints¶
,step <expr> — Single-step evaluation¶
,delete all — Clear all breakpoints¶
Runtime¶
,gc — Show GC statistics¶
kaappi> ,gc
GC Statistics:
Collections: 42
Live objects: 1523 (peak: 3201)
Heap size: 48736 bytes (peak: 102400)
...
,help — Show all commands¶
kaappi> ,help
Commands:
,time <expr> Measure execution time
,type <expr> Show result type
,describe <sym> Show procedure arity and type
,apropos <str> Search bindings by substring
,env [prefix] List global bindings by prefix
,profile <expr> Profile timing, calls, and allocations
,expand <expr> Show macro expansion
,gc Show GC statistics
,break <name> Set breakpoint on function
,breakpoints List active breakpoints
,delete all Clear all breakpoints
,step <expr> Evaluate with single-stepping
,help This message
The variable _ holds the last result.
Exiting¶
Or press Ctrl+D on an empty line.
Next: Tips