docs: Finch's self-hosting gap, as it stands

Sized numbers, methods, defer, errors as values and maps are now in the
self-hosted compiler; C import is the one piece left.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015f73FesGZGYPkmDvUcj6QX
This commit is contained in:
Nexoniarz 2026-10-25 18:55:31 +01:00
commit afb2e084af

View file

@ -59,28 +59,31 @@ Measured from the repository, not from its README alone:
## The self-hosting gap
"Rewrite it in Finch itself" is mostly done: `boot/` compiles itself. What it
does **not** yet do is stated by its own test, `tests/boot.sh`, which skips
every test that uses a feature `boot/` lacks. Counting mentions in the two
sources confirms it (`boot/` vs `src/`):
"Rewrite it in Finch itself" was mostly done before this was written: `boot/`
compiled itself. What it lacked is stated by its own test, `tests/boot.sh`,
which skips every test using a feature `boot/` does not have. Measured against
that test, on the branch `finish-finch` of the Finch repository (kept in the
author's checkout, `Projects/Finch`, as a branch on top of `embed`):
| Feature | `boot/` | `src/` | Needed for |
|---|---|---|---|
| maps | 0 | 185 | `codegen_map.cpp` (242 lines) to port |
| errors as values (`or`, `try`) | few | hundreds | most real programs |
| methods on user types | 17 | 87 | partial |
| `defer` | 2 | 31 | partial |
| sized numbers (`u8`..`u64`, `i8`..`i32`, `f32`, `f64`) | none | throughout | kernel-facing code |
| enums | 0 | 14 | |
| C import (`import "x.h"`, `link`) | none | `cimport.cpp`, 373 lines on libclang | **the way into every C library, SchOS's included** |
| target and ABI layer (AArch64, macOS, Windows) | 0 | `target.cpp`, `abi.cpp` | non-Linux-x86 targets |
| language server | 0 | `lsp.cpp`, 580 lines | editors |
| Feature | `boot/` | Notes |
|---|---|---|
| sized numbers (`i8`..`u64`, `f32`), conversions | **done** | `int` and `float` stay the i64 and f64 defaults |
| methods (`fn T.m`), mutation analysis | **done** | |
| `defer` | **done** | |
| errors as values (`-> T!`, `error`, `try`, `or`) | **done** | including `fn main() -> !` |
| maps, `for k, v in`, `for i, x in` | **done** | |
| `str(x)` of any value | **done** | |
| **C import** (`import "x.h"`, `link`, C structs by value) | **missing** | the one that matters for SchOS: libclang through Finch's own C import, then the System V struct ABI |
| target and ABI layer (AArch64, macOS, Windows) | missing | after C import |
| language server | missing | `lsp.cpp`, 580 lines |
So "finishing" has a concrete order: **errors as values and maps first** (they
are what the rest uses), then sized numbers and `defer`, then C import — which
needs libclang bindings, so it needs C import's own simpler form first — and
the target layer last. `tests/boot.sh` is the measure: the list of skipped
tests shrinks to nothing.
The self-hosted compiler passes 17 of 22 tests and compiles itself to
byte-identical output; the five it skips all import C. **C import is the next
piece, and the last one before the C++ compiler is only a seed.** It is a few
thousand lines of Finch (`cimport.cpp` and `abi.cpp` are 740 in C++), done in two
steps so each can be tested: functions, constants, globals and pointers first
(`cimport`, `c_pointers`), struct layout and the calling convention second
(`c_structs`).
The scratch files `note.txt` and `notatka.txt` in the repository are not
Finch's and can go.