The REPL section: line editing, Tab completion and :complete.
The REPL no longer relies on rlwrap. Say what it does at a terminal instead (history, Enter continuing an open form), how Tab completes, and that :complete gives editors the same completions. 🤖 Generated with [ECA](https://eca.dev) Co-Authored-By: eca-agent <git@eca.dev>
This commit is contained in:
parent
5735643b05
commit
bc58247994
1 changed files with 10 additions and 1 deletions
|
|
@ -1315,7 +1315,7 @@ Because @code{with-fake-fs} is implemented via algebraic effects, test modules u
|
||||||
|
|
||||||
@subsubsection{The REPL}
|
@subsubsection{The REPL}
|
||||||
|
|
||||||
You can launch an interactive Read-Eval-Print Loop by running @code{bjo repl}. When invoked inside a project directory, the REPL automatically discovers and allows importing any of the project's local modules. The REPL delegates terminal line editing to @code{rlwrap} if it is present on your system. Submitting an expression evaluates it and prints the result, while entering definitions compiles them and prints the bound names:
|
You can launch an interactive Read-Eval-Print Loop by running @code{bjo repl}. When invoked inside a project directory, the REPL automatically discovers and allows importing any of the project's local modules. At a terminal the REPL edits its own lines and keeps a history across sessions. Pressing Enter while a bracket is still open starts a new line, so a long form can be written and edited over several lines. Submitting an expression evaluates it and prints the result, while entering definitions compiles them and prints the bound names:
|
||||||
|
|
||||||
@codeblock[#:lang "text"]|{
|
@codeblock[#:lang "text"]|{
|
||||||
bjo> (+ 1 2)
|
bjo> (+ 1 2)
|
||||||
|
|
@ -1378,6 +1378,15 @@ bjo> :show random-u
|
||||||
|
|
||||||
Import modifiers apply as they would in an entry: after @code{(import (prefix (std random) "r/"))} the name to ask about is @code{r/random-bool}, and @code{:show} says that it is @code{random-bool} from @code{(std random)}. A name with no documentation is shown with where it comes from and "with no doc".
|
Import modifiers apply as they would in an entry: after @code{(import (prefix (std random) "r/"))} the name to ask about is @code{r/random-bool}, and @code{:show} says that it is @code{random-bool} from @code{(std random)}. A name with no documentation is shown with where it comes from and "with no doc".
|
||||||
|
|
||||||
|
Tab completes the name at the cursor from the same names, together with the special forms and the names the entry you are typing has already bound. When only one name fits it is inserted, and when several do, the part they share is inserted and pressing Tab again opens a menu showing each name's signature and summary. Inside an import, Tab completes module paths instead: @code{(import (std ra} becomes @code{(import (std random}.
|
||||||
|
|
||||||
|
The same completions are available as a command, @code{:complete text}, which prints the names that could be written at the end of @code{text}, one per line followed by where each comes from. It is meant for editors rather than people: an editor can send the entry up to the cursor and offer what comes back.
|
||||||
|
|
||||||
|
@codeblock[#:lang "text"]|{
|
||||||
|
bjo> :complete (random-in
|
||||||
|
random-int (std random)
|
||||||
|
}|
|
||||||
|
|
||||||
Type @code{:help} to view available REPL commands, or press @code{Ctrl-D} (or type @code{:quit}) to exit.
|
Type @code{:help} to view available REPL commands, or press @code{Ctrl-D} (or type @code{:quit}) to exit.
|
||||||
|
|
||||||
@subsection{Performance}
|
@subsection{Performance}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue