Scopes work in ordinary code, and macros can write by-colour

The Scopes section shows a with-scope in a defun, and own!, own-disposable
and release!. The Macros section has a section on by-colour.

🤖 Generated with [ECA](https://eca.dev) (anthropic/claude-opus-5-5)

Co-Authored-By: eca-agent <git@eca.dev>
This commit is contained in:
Linus Björnstam 2026-10-10 22:45:31 +02:00
parent 8ca519a8ed
commit bb8cefba19
2 changed files with 56 additions and 2 deletions

View file

@ -310,7 +310,7 @@ Bjolang solves this problem at the compiler level using @em{colour twins}:
2. Source-level twin generation: Before type checking occurs, the @code{ColourTwins} pass scans all declarations. When it detects a function with a @code{-?->} parameter, it automatically generates a second definition from the same source body, repainted with suspending signatures. Both definitions are checked independently. This ensures that effects and await points are fully verified without needing error-prone AST copying after inference.
3. Reaching twins: Any function defined with @code{defun} that calls a dual-mode function (such as @code{defbjouble} primitives that provide both synchronous and fiber implementations) automatically receives a suspending twin as well. If an author explicitly wants a function to remain strictly synchronous, they can mark it with @code{#:sync}.
3. Reaching twins: Any function defined with @code{defun} that calls a dual-mode function (such as @code{defbjouble} primitives that provide both synchronous and fiber implementations) automatically receives a suspending twin as well, and so does one with a @code{(by-colour ...)} in it, whose @code{#:bjo} body goes into the twin and whose @code{#:sync} body stays in the original. If an author explicitly wants a function to remain strictly synchronous, they can mark it with @code{#:sync}.
4. Automatic call-site selection: When a function is called, the compiler checks the colour of the caller. If an ordinary @code{defun} calls @code{list-map}, it calls the synchronous twin. If a bjoroutine (@code{defbjo}) calls @code{list-map} with a suspending callback, it automatically links to the suspending twin. The author writes the higher-order function once, and the language transparently provides both versions.