REPL
The REPL (read-eval-print loop) runs Kiwi code as you type it. Start it by running kiwi with no script, or with kiwi -i:
$ kiwikiwi 1.8.0 - type 'exit' or press Ctrl+C to quit.>>The standard library is loaded, so every package is ready to use. Named arguments given on the command line are available through env::argv():
$ kiwi -name=ada>> env::argv()=> {"name": "ada"}Evaluating code
Section titled “Evaluating code”Each input runs as soon as you press Enter. When the input produces a value other than null, the REPL prints it after =>, so you rarely need println:
>> 1 + 2=> 3>> "hello".uppercase()=> "HELLO">> x = 10=> 10>> [1 to 5].map(do (n) => n * x)=> [10, 20, 30, 40, 50]>> println "printed output"printed outputVariables, functions and structs you define stay available for the rest of the session.
Multi-line input
Section titled “Multi-line input”When a line opens a block (fn, if, for, struct and so on) the prompt changes to .. and the REPL waits until the block is complete:
>> fn square(n).. n * n.. end>> square(7)=> 49End a line with \ to continue a statement on the next line without opening a block:
>> total = 1 + \.. 2 + 3=> 6Key bindings
Section titled “Key bindings”| Keys | Action |
|---|---|
| ← / → | Move the cursor |
| Home / Ctrl+A | Start of line |
| End / Ctrl+E | End of line |
| Backspace / Delete | Delete before / at the cursor |
| Ctrl+K | Delete to the end of the line |
| Ctrl+U | Delete to the start of the line |
| Ctrl+W | Delete the word before the cursor |
| ↑ / ↓ | Previous / next history entry |
Leaving
Section titled “Leaving”Type exit or .exit, press Ctrl+D on an empty line, or press Ctrl+C.