lib/session.ml holds the declarations a running process was built from plus every change accepted since, which is what an editor needs and what a one-shot compiler cannot have. Transactionality came for free. Check.program builds a fresh environment from a declaration list on every call, so a form that fails to check mutates nothing and the accumulated list is simply not replaced - no scratch-environment machinery, which is what I was about to build. Re-checking the whole program each evaluation costs the frontend, under 10ms, less than the llc after it. There is a test for the case that matters: a typo, then a good form, in the same session. Which names the process was built with comes from the checked program, not from any accumulated AST, because Check.program prepends the prelude and no AST contains it. Derive it from declarations and print-line reads as new, gets a registry cell nobody publishes, and the first call jumps to null. Three changes are refused with a reason rather than loaded. A function's signature, because a cell is a bare ptr and every call site compiled before the change still passes the old arguments through it. A global's type, because the storage exists and has a shape - reusing it reads at the wrong offsets, and replacing it discards the state the reload exists to preserve. A struct's fields, because the values the process is holding have the old layout. Note what the checker already catches on its own: change a parameter type and the caller fails to type check first, loudly. These rules only get a turn on a change the checker accepts, which is a name nothing else in the program uses - exactly where the silent version lives. Hence an unused defvar and a C-called defn in the fixtures. The accumulated list is the post-Load one, so an evaluated import is spliced as its expansion. Otherwise re-evaluating a file that imports something appends a second import, Load expands it again, and the duplicate-name pass rejects it. C-c C-k on sand.flan's own text is the test. flan reload now takes a program and a file of changed forms rather than a list of function names and a --new list: the session works out which names are new, which is the thing a bare CLI could not. Also fixed, found by running the agent test under load: the agent took SIGPIPE when a sender read part of a reply and closed. Replies go out with MSG_NOSIGNAL, per call rather than by installing a handler, because the signal disposition belongs to the program the agent is embedded in.
Description
Languages
OCaml
67.2%
Emacs Lisp
15.2%
C
10.4%
HTML
2.9%
Standard ML
2.8%
Other
1.5%