Skip to the content
Diaspar

Decision D018 · accepted as a goal; details proposed

A running program can be connected to and changed without a restart

A record of the language's design, as it stood on 2026-11-18: written for the people who build Diaspar, and kept as it was written. Its code is a sketch, not a program of the site, and an older record may show syntax that a later one changed. It names files of the language's source, which is not public yet.

Status: accepted (2026-11-15) as a goal; proposed for the details; built after the REPL debugger (D017)

Decision

diaspar run --repl starts a program together with a REPL server. An editor, a terminal, or a coding agent connects to it and works inside the running program:

  • evaluates code in the program's own state: inspects values, calls functions;
  • redefines functions, and the running program uses the new versions at once, through global cells (D003);
  • runs tests (D016);
  • gets the debugger (D017) when the program hits an unhandled error: the failing task freezes and waits for the connected user, while the rest of the program goes on (D006).
$ diaspar run --repl game.dias
repl: listening on /run/user/1000/diaspar/game.sock

$ diaspar connect
game=> (.hp (player-state))
73
game=> (defn jump-height [p] (* 1.5 (base-jump p)))   ; the running game jumps higher at once
game.jump-height ; redefined

A game is tuned while it plays, and a server is fixed while it serves, without losing their state.

Prior art

  • Erlang's remote shell and hot code loading: production systems updated without stopping.
  • Clojure's nREPL and socket REPL, used in running services.
  • Common Lisp with SLIME/Swank: in 1999 NASA's Deep Space 1 Remote Agent, written in Lisp, was debugged through a REPL on the spacecraft.
  • Smalltalk images.

Rules

  • Every build except a sealed one is live. Calls are guarded direct calls, so redefinition reaches compiled code in release builds too (D026); a --sealed build has no cells, and --repl on it is an error.
  • Local by default. The server listens on a Unix socket or localhost only, and requires a token. Listening on a network address needs an explicit option.
  • A REPL connection is full authority. It can do anything the program can, so it is never enabled implicitly in release builds, and the program can restrict what a session may do through capabilities (D005).
  • Fibers keep running old code (proposed, 2026-11-17, D035). New calls go to the new definition; a fiber suspended in the middle of a function finishes it on the old code, which is never unmapped. The REPL shows how many fibers still run each retired version (design/concurrency.md §7).
  • One protocol (D020). The connection speaks the same machine-readable REPL protocol as the local REPL and the debugger (D014, D017), so editors and agents need one client.

Open questions

  • What happens to values of a type redefined in a running program (D010 gives the rule for the REPL; servers may need explicit migrations).
  • Updating a long-running program safely: a whole module at once, as Erlang does, rather than function by function.