The REPL environment provides the usual APIs from Janet's core library, plus some global variables exported by Jwno (they all have the jwno/
prefix):
Global Variable | Description |
---|---|
jwno/context | The context object containing all the states tracked/used by Jwno's main thread. REPL connections also run in the main thread (but in different fibers), so you can access most parts of this object in the REPL directly and safely, without triggering race conditions and the like. |
jwno/user-config | The environment object that results from evaluating the config file. All top-level bindings in the config file are accessible in this environment. For example, you can access a variable named my-awesome-keymap like this: (in jwno/user-config 'my-awesome-keymap) . Alternatively, you can do (import jwno/user-config) in the REPL, and access user-config/my-awesome-keymap directly. |
jwno/repl-server | The REPL server we connected to. |
jwno/client-name | The name for the current REPL client, as shown in the REPL prompt. |
jwno/client-stream | The socket stream for the current REPL client. |
Every REPL connection has its own environment. Everything referenced in an REPL session will be cleared when it's closed. And if you defined a variable in one REPL session, it will not be accessible in other REPL sessions. To make something persist, and be accessible to all REPL sessions, you can export it:
(import jwno/util)
(def the-answer 42)
(util/export-to-repl jwno/repl-server the-answer)
And of course you can remove exported names:
(util/unset-from-repl jwno/repl-server the-answer)