From 55daceac04083a8d95547aa354353592466d86bc Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Wed, 14 Oct 2026 13:47:39 +0100 Subject: [PATCH] PROPOSALS.md in place of PLAN.md; the book dropped for now PLAN.md had no milestone under way; what it held of value, the const parameter, is now the one proposal in PROPOSALS.md. The book brief, doc/book/PLAN.md, goes until it is wanted again. References follow. --- diff --git a/CLAUDE.md b/CLAUDE.md index bb30bfe..b24f166 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,10 +1,10 @@ # Working on raz -Read `PLAN.md` (the milestone under way and its steps), `doc/raz.md` -(the language report, volume 1) and `doc/compiler.md` (the guide to the -compiler) first; `doc/raz-lib.md` is volume 2, the library, and -`doc/report-history.md` what each version of the report changed. The report defines the language; where the plan -disagrees, the report wins and the plan is fixed. +Read `doc/raz.md` (the language report, volume 1) and +`doc/compiler.md` (the guide to the compiler) first; `doc/raz-lib.md` +is volume 2, the library, `doc/report-history.md` what each version of +the report changed, and `PROPOSALS.md` what waits for a thaw. The +report defines the language. ## Setup and checks @@ -53,7 +53,7 @@ no classes, ansistrings, exceptions, dynamic arrays or SysUtils), so it uses nothing the seed doesn't know until a release makes a new seed. -- Plans go by milestones, each a release (`PLAN.md`). A milestone +- Work goes by milestones, each a release, set by the owner. A milestone starts only on the owner's explicit go-ahead; within it, one commit per step, pushed as it is done, then stop for review. Never start a milestone, or change the report's language, without being asked. @@ -82,7 +82,7 @@ compiler in raz, built by itself (Self, done); the seed in `seed/` is frozen, and v0.9.1 was the last release it built. The compiler takes 1.4 times the Pascal one's time; `make kernels` measures `test/bench` -against FPC `-O2`. Next, by `PLAN.md`: what the owner chooses. What +against FPC `-O2`. Next: what the owner chooses. What each version of the report changed is in `doc/report-history.md`, and what each step did is in git; don't repeat it here. @@ -93,8 +93,8 @@ **The freeze.** Since v0.5.0 the language changes only to mend a defect, and the library grows only by what breaks no program written -for it. A wish for more, the owner's or yours, goes on the list in -`PLAN.md`, for a later thaw; it isn't built. Thaws happen only by the +for it. A wish for more, the owner's or yours, goes in +`PROPOSALS.md`, for a later thaw; it isn't built. Thaws happen only by the owner's word (v0.6.0, and reports 2026-10.13 to 10.23). The parser reaches the machine only through `Gen.raz`. Keep @@ -117,12 +117,12 @@ ## The compiler and the seed -`src/` is the compiler, in raz (`PLAN.md`, "Self"): one module to a +`src/` is the compiler, in raz: one module to a seed unit, the same names. `seed/`, the Free Pascal compiler it was ported from, is the **seed**: frozen at its last version, kept to build `src/` the first time and as the reference its units are tested against, and to be dropped in time. Never edit the seed; a difference -found goes on the plan, for the owner. +found is told to the owner. `sbcl/` is an example, not part of the build: a second compiler, in Common Lisp, written from the report alone and kept as a reference diff --git a/PLAN.md b/PLAN.md deleted file mode 100644 index dad5144..0000000 --- a/PLAN.md +++ /dev/null @@ -1,42 +0,0 @@ -# raz: the plan - -Work goes by milestones, each a release. A milestone says what it is -for, what is in it and when it is done; its steps are commits, each -stopping for the owner's review. A finished milestone is cut from this -file: git keeps the history, and the report's history, `doc/report-history.md`, the language's. - -v0.11.1, report 2026-10.23, is the latest release. All before v0.7.1 -is approved by the owner; v0.7.1, v0.8.0, v0.9.0 and v0.9.1 wait for -the owner's review. No milestone is under way: the last, Self (the -compiler in raz, built by itself), is done, and `seed/` is frozen. - -## Next, when the owner says - -- The book, "Compiling Raz": its brief is `doc/book/PLAN.md`. -- The compiler's last 0.1 of the 1.3: an inliner for the small procedures - that are one expression (`Gen.drop`, `X64.mem`, `Chunk.put1`, `Scan.tokPos`) - would take call overhead off some 15% of the instructions; `chooseRegs` - reads each procedure twice, which is 13% of the time; and `Mem`, `Item` - and `Adr` are records copied at each call that passes them on. -- A port to aarch64, to measure one: a new `Gen.raz`, an encoder and - assembler for it, and its ELF. - -## Wishes, for a later thaw - -What the language or the library might have, met while writing raz; -none is built while the freeze holds. - -- **`inline`, a hint** (dropped, 2026-10.13): a hint means nothing a - program can see, and this compiler can inline by itself, with no - keyword. Measured: `test/bench/Grep` with its helpers inlined by hand - ran 30% faster; rat's hot procedures gained nothing from it, but 12% - from hoisting two fast paths by hand (`Width.cells`, - `Screen.unsplit`), which is an inliner several times the size. Revisit - only if more programs show it. -- **A `const` parameter.** `proc what(const x: Item): []U8;`: the callee - may not change `x` (nor take its address), so the caller may pass the - address of a record or array without a copy, and the program means the - same. Met in Self step 3b, where the seed's `const x: TItem` (about 130 - bytes) became a value parameter, copied at every call. Measured in Self - step 4: not what stands out, the compiler's profile is flat - (`Scan.tokPos` is 9%). diff --git a/PROPOSALS.md b/PROPOSALS.md new file mode 100644 index 0000000..1edb268 --- /dev/null +++ b/PROPOSALS.md @@ -0,0 +1,16 @@ +# raz: proposals + +What the language or the library might have, met while writing raz. +None is built while the freeze holds; each waits for a later thaw, by +the owner's word, and goes into the report before any code. + +## A `const` parameter + +`proc what(const x: Item): []U8;`: the callee may not change `x` (nor +take its address), so the caller may pass the address of a record or +array without a copy, and the program means the same. + +Met in porting the compiler to raz, where the seed's `const x: TItem` +(about 130 bytes) became a value parameter, copied at every call. +Measured once the port built: not what stands out, the compiler's +profile is flat (`Scan.tokPos` is 9%). diff --git a/README.md b/README.md index 0a3e978..13b24f3 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ | `conform/` | The conformance suite: what every implementation must do | | `sbcl/` | An example: a second compiler, in Common Lisp for SBCL, written from the report alone and kept as a reference; it passes `conform/` and builds `src/` into a compiler that makes the same bytes. Not part of the build | | `test/` | This compiler's own tests, and the scripts that run them | -| `PLAN.md` | The plan: the milestone under way and its steps | +| `PROPOSALS.md` | What the language might have, waiting for a later thaw | ## Building @@ -223,7 +223,7 @@ Since v0.5.0 the language is frozen, softly: it changes only to mend a defect, and the library grows only by what breaks no program. Wishes -wait on a list in `PLAN.md`, for a later thaw; v0.6.0 was one, for a +wait in `PROPOSALS.md`, for a later thaw; v0.6.0 was one, for a language anyone can build again from its report. ## Not here diff --git a/doc/book/PLAN.md b/doc/book/PLAN.md deleted file mode 100644 index 96f7006..0000000 --- a/doc/book/PLAN.md +++ /dev/null @@ -1,106 +0,0 @@ -# Stage: the book "Compiling Raz" - -This is the owner's go-ahead for a new stage: a book, "Compiling Raz", -explaining how the raz compiler works. Follow CLAUDE.md's way of working: -one commit per step, push it, then stop for review. Don't change the -language or the compiler for the book's sake. If the book exposes a bug -or a clumsy spot, report it rather than fixing it. - -## Read first -- CLAUDE.md, doc/raz.md (the report), doc/compiler.md, README.md. -- seed/*.pas, the whole compiler (about 5,000 lines), and enough of lib/ - (Rt, Heap, Mem, Thread, Sys) to explain the runtime. -- The tiza skill, for drawings. - -## The reader -A working programmer: not good at Pascal, little knowledge of compilers. -- Assume they roughly know registers, the stack and memory. Explain only - what raz does with them (frames, calling convention, layout). -- Introduce compiler ideas (tokens, grammar, generating code while - parsing, symbol tables) briefly and in friendly terms where they first - appear. -- Teach just enough Pascal to read the compiler: one early chapter, then - more as features come up. Teach enough raz the same way. -- Keep the two languages visibly apart: ```raz and ```pascal code blocks, - and say which one is on screen. -- Don't explain formats that can be looked up. ELF gets a page on what - raz writes and why, plus a pointer to the spec. -- Target 40-50k words. - -## Tone -Like Learn You a Haskell and Starting FORTH: tiny steps, talking straight -to the reader, every idea shown at once on a real example, drawings that -carry meaning. Warm, with an occasional dry aside. Never a joke per -paragraph; humor is seasoning. Plain, short sentences. - -## Mascot: Razmataz -A small, very serious creature with a flashy name, which suits a frugal -compiler (razzmatazz minus one z). -- Its motto, "once is enough", plays on "raz" meaning "one" or "once" in - Polish and Russian. Check that the compiler really works in one pass - before leaning on this; if it doesn't, find the honest version of the - joke. -- Razmataz appears in tiza drawings: eating characters in the scanner, - stacking boxes in frames, throwing unused code overboard in linking. - -## Structure -Build up gradually, not unit by unit: -1. Introduction and a whirlwind tour: compile `exit 42` (or the smallest - real program) through every stage, shallowly. -2. Enough Pascal (and raz) to follow along. -3. One chapter per language feature, followed through scanner, parser, - symbols, code generator and machine code: variables and expressions, - control flow, procedures and frames, records and arrays, pointers and - the heap, strings, modules, defer, C interop, threads. -4. Closing chapters: x64 encoding, link (tree shaking, layout), elf, - speed (how it reaches 400k lines a second), and where to go next. - -Refine this order in the outline (step 1). - -## Format and tooling -- Markdown in doc/book/: NN-slug.md per chapter, plus metadata.yaml - (title, author Luis, cover). It must read well as plain text. -- `make book` builds build/compiling-raz.epub with pandoc. If pandoc gets - installed locally, update the desktop guide (see the global - CLAUDE.md). -- Drawings: .tiza source and a rendered PNG, both committed (CI has no - tiza). Every image has a caption that stands on its own in plain text. - Use ASCII art in code blocks for diagrams that are really structure - (frames, memory layout); those read the same in both formats. -- Disassembly is cleaned up: instructions only, the raz source line - beside them as a comment, and bytes only where the bytes are the point. - Show raw objdump output once, early, next to the cleaned version, and - say how to get it. -- A checker, written in raz alongside tools/Doc.raz (reuse what exists), - run by `make check`. It must: - - compile and run every raz example marked as runnable and compare the - expected output written in the book; - - confirm every quoted Pascal excerpt still matches seed/, quoted by - unit and routine name, never by line number; - - regenerate or verify the cleaned disassembly. - The goal: when the compiler changes, `make check` fails rather than - the book going quietly wrong. -- CI (.github/workflows/): on a push to main that touches doc/book/**, - seed/** or lib/**, build the epub and replace the file on a standing - prerelease tagged `book` (gh release upload --clobber), so the owner - has a fixed URL to open on an iPad. Tagged releases also attach that - version's epub. - -## Steps (each one is a commit, then stop for review) -1. The outline: doc/book/OUTLINE.md, chapter by chapter, with what each - one teaches, its running example, and the drawings planned. -2. The tooling: doc/book/ skeleton, `make book`, the checker in - `make check`, the CI job. One placeholder chapter proves the pipeline - end to end. -3. Razmataz's design sheet (tiza) and one sample chapter, the procedures - and frames one, to set tone and depth. -4. Then one chapter per step, in order. - -doc/compiler.md stays as it is: the short guide for people changing the -compiler. The book can point to it but never replaces it. - -## Left to the tooling step -- How the checker marks runnable examples and quoted excerpts inside - Markdown. -- Whether the cleaned disassembly comes from the compiler's own line - information (`make gdb` suggests it has some) or from objdump. diff --git a/doc/compiler.md b/doc/compiler.md index 11d39d2..2faa1c2 100644 --- a/doc/compiler.md +++ b/doc/compiler.md @@ -737,8 +737,8 @@ in `Obj`, a cache of the names found by `chooseRegs`' look-ahead, and passing `Item` to `adrOf` as a `var` parameter, so as not to copy it. What is left is spread thinly: the procedure call overhead of many small -routines (`Gen.drop`, `X64.mem`, `Chunk.put1`, which an inliner, listed -in `PLAN.md`, would remove), the reading of every procedure twice, and +routines (`Gen.drop`, `X64.mem`, `Chunk.put1`, which an inliner +would remove), the reading of every procedure twice, and a record parameter copied at each call that passes it on (`Mem`, in the encoder). diff --git a/src/README.md b/src/README.md index be2e1c0..872e005 100644 --- a/src/README.md +++ b/src/README.md @@ -1,7 +1,6 @@ # src: the compiler in raz The port of the Pascal compiler, the **seed** in `../seed/`, to raz. -`../PLAN.md`, "Self", says what it is for and the order of its units. One module to a seed unit, with the seed's name, written to the same rules: plain code, each module opening with what it is, what it @@ -137,7 +136,7 @@ same; whether the compiler built from this is slower for it is for the speed test of step 4 to say. A `const` parameter (a hint that the callee won't change it, so that the caller may pass its address) - would be a language change: it goes on the wish list. + would be a language change: it is in `../PROPOSALS.md`. - **`Parse` and the seed's jumps.** The seed's `Guard`, `setjmp` and `longjmp` are `guard`, a record of what to put back, and the `ERROR` that comes up through `try` to the statement or declaration that is