REPL usage - anssihalmeaho/funl GitHub Wiki
FunL REPL is interactive shell which reads user inputs, evaluates those, prints result and continues this until user wants to quit.
REPL is started with -repl option:
./funla -repl
Welcome to FunL REPL (interactive command shell)
funl>
Evaluating expressions:
funl> plus(1 2 3)
6
funl>
There's help:
funl> help
Input can be:
help -> prints this help
? -> prints this help
quit -> exits repl
exit -> exits repl
<expression> -> evaluates expression and prints result
Adding < to end of line causes repl to gather more input before evaluation
funl>
Using <symbol> = <expression> syntax cannot be used in REPL directly
(as it's not expression).
Instead let -operator should be used for this purpose.
funl> let(x list(1 2 3))
list(1, 2, 3)
funl> x
list(1, 2, 3)
funl> len(x)
3
funl>
Importing modules cannot be done with import <module> syntax
(as it's not expression).
Instead imp -operator should be used for this purpose.
funl> let(m imp(stdstr))
map('is-upper' : ext-proc, 'rstrip' : ext-proc, 'lowercase' : ext-proc, 'strip' : ext-proc, 'endswith' : ext-proc, 'is-digit' : ext-proc, 'join' : ext-proc, 'is-alpha' : ext-proc, 'is-space' : ext-proc, 'is-alnum' : ext-proc, 'is-lower' : ext-proc, 'replace' : ext-proc, 'uppercase' : ext-proc, 'startswith' : ext-proc, 'lstrip' : ext-proc)
funl>
funl> m
map('is-upper' : ext-proc, 'rstrip' : ext-proc, 'lowercase' : ext-proc, 'strip' : ext-proc, 'endswith' : ext-proc, 'is-digit' : ext-proc, 'join' : ext-proc, 'is-alpha' : ext-proc, 'is-space' : ext-proc, 'is-alnum' : ext-proc, 'is-lower' : ext-proc, 'replace' : ext-proc, 'uppercase' : ext-proc, 'startswith' : ext-proc, 'lstrip' : ext-proc)
funl>
funl> let(lowercase get(m 'lowercase'))
ext-proc
funl>
funl> call(lowercase 'AB cd')
ab cd
funl>
funl> keys(m)
list('is-upper', 'rstrip', 'lowercase', 'strip', 'endswith', 'is-digit', 'join', 'is-alpha', 'is-space', 'is-alnum', 'is-lower', 'replace', 'uppercase', 'startswith', 'lstrip')
funl>
Adding "<" to end of line causes repl to gather more input before evaluation.
funl>
funl> let(p <
funl>... proc() <
funl>... 'ok' <
funl>... end)
func-value: file: line: 1 pos: 11
funl>
funl> call(p)
ok
funl>