From 96d6ebc8e29e94920cce337c21346b40954459afda134f5a1296a9fe103813de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Bj=C3=B6rnstam?= Date: Mon, 5 Oct 2026 21:42:58 +0200 Subject: [PATCH] The REPL's :show prints the doc of a visible name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [ECA](https://eca.dev) Co-Authored-By: eca-agent --- _02_.Writing-programs.sz | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/_02_.Writing-programs.sz b/_02_.Writing-programs.sz index d2a7bf3..8fa1f90 100644 --- a/_02_.Writing-programs.sz +++ b/_02_.Writing-programs.sz @@ -1312,4 +1312,29 @@ bjo> (g 10) 12 }| -The same incremental compilation model applies to trait implementations (@code{impl}): an implementation entered at the prompt is visible to subsequent entries, but cannot retroactively modify calls compiled earlier. Type @code{:help} to view available REPL commands, or press @code{Ctrl-D} (or type @code{:quit}) to exit. +The same incremental compilation model applies to trait implementations (@code{impl}): an implementation entered at the prompt is visible to subsequent entries, but cannot retroactively modify calls compiled earlier. + +@code{:show name} prints the documentation of a name you can use at the prompt: what it is, where it comes from, how it is called, and the text its author wrote in a @code{(:doc ...)} form. It then lists the other usable names containing the text, in any case, with their modules and one-line summaries. Only names that an entry typed now could use are considered, that is builtins, names your imports bring in, and names defined at the prompt. So @code{:show random-bool} prints nothing until @code{(std random)} is imported: + +@codeblock[#:lang "text"]|{ +bjo> :show random-bool +bjo> (import (std random)) +bjo> :show random-bool +random-bool: function from (std random) + (random-bool #:rng (parameter-ref current-random)) + : (-> (#:rng RandomSource) bool) + + #t or #f, equally likely. + + #:rng The source to draw from. + returns One random bit. They are drawn 64 at a time. + + See also: random-chance? +bjo> :show random-u + random-u32 (std random) 32 random bits. + random-u64 (std random) 64 random bits. +}| + +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". + +Type @code{:help} to view available REPL commands, or press @code{Ctrl-D} (or type @code{:quit}) to exit.