raz / commit 55daceac

commit
55daceac04083a8d95547aa354353592466d86bc
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
4efc5101
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.

patch · log

7 files changed, +32 -165

CLAUDE.md modified +11 -11

@@ -1,10 +1,10 @@
11 # Working on raz
22
3-Read `PLAN.md` (the milestone under way and its steps), `doc/raz.md`
4-(the language report, volume 1) and `doc/compiler.md` (the guide to the
5-compiler) first; `doc/raz-lib.md` is volume 2, the library, and
6-`doc/report-history.md` what each version of the report changed. The report defines the language; where the plan
7-disagrees, the report wins and the plan is fixed.
3+Read `doc/raz.md` (the language report, volume 1) and
4+`doc/compiler.md` (the guide to the compiler) first; `doc/raz-lib.md`
5+is volume 2, the library, `doc/report-history.md` what each version of
6+the report changed, and `PROPOSALS.md` what waits for a thaw. The
7+report defines the language.
88
99 ## Setup and checks
1010
@@ -53,7 +53,7 @@
5353 no classes, ansistrings, exceptions, dynamic arrays or SysUtils), so
5454 it uses nothing the seed doesn't know until a release makes a new
5555 seed.
56-- Plans go by milestones, each a release (`PLAN.md`). A milestone
56+- Work goes by milestones, each a release, set by the owner. A milestone
5757 starts only on the owner's explicit go-ahead; within it, one commit
5858 per step, pushed as it is done, then stop for review. Never start a
5959 milestone, or change the report's language, without being asked.
@@ -82,7 +82,7 @@
8282 compiler in raz, built by itself (Self, done); the seed in `seed/` is
8383 frozen, and v0.9.1 was the last release it built. The compiler takes
8484 1.4 times the Pascal one's time; `make kernels` measures `test/bench`
85-against FPC `-O2`. Next, by `PLAN.md`: what the owner chooses. What
85+against FPC `-O2`. Next: what the owner chooses. What
8686 each version of the report changed is in `doc/report-history.md`, and
8787 what each step did is in git; don't repeat it here.
8888
@@ -93,8 +93,8 @@
9393
9494 **The freeze.** Since v0.5.0 the language changes only to mend a
9595 defect, and the library grows only by what breaks no program written
96-for it. A wish for more, the owner's or yours, goes on the list in
97-`PLAN.md`, for a later thaw; it isn't built. Thaws happen only by the
96+for it. A wish for more, the owner's or yours, goes in
97+`PROPOSALS.md`, for a later thaw; it isn't built. Thaws happen only by the
9898 owner's word (v0.6.0, and reports 2026-10.13 to 10.23).
9999
100100 The parser reaches the machine only through `Gen.raz`. Keep
@@ -117,12 +117,12 @@
117117
118118 ## The compiler and the seed
119119
120-`src/` is the compiler, in raz (`PLAN.md`, "Self"): one module to a
120+`src/` is the compiler, in raz: one module to a
121121 seed unit, the same names. `seed/`, the Free Pascal compiler it was
122122 ported from, is the **seed**: frozen at its last version, kept to build
123123 `src/` the first time and as the reference its units are tested
124124 against, and to be dropped in time. Never edit the seed; a difference
125-found goes on the plan, for the owner.
125+found is told to the owner.
126126
127127 `sbcl/` is an example, not part of the build: a second compiler, in
128128 Common Lisp, written from the report alone and kept as a reference

PLAN.md (history) deleted +0 -42

@@ -1,42 +0,0 @@
1-# raz: the plan
2-
3-Work goes by milestones, each a release. A milestone says what it is
4-for, what is in it and when it is done; its steps are commits, each
5-stopping for the owner's review. A finished milestone is cut from this
6-file: git keeps the history, and the report's history, `doc/report-history.md`, the language's.
7-
8-v0.11.1, report 2026-10.23, is the latest release. All before v0.7.1
9-is approved by the owner; v0.7.1, v0.8.0, v0.9.0 and v0.9.1 wait for
10-the owner's review. No milestone is under way: the last, Self (the
11-compiler in raz, built by itself), is done, and `seed/` is frozen.
12-
13-## Next, when the owner says
14-
15-- The book, "Compiling Raz": its brief is `doc/book/PLAN.md`.
16-- The compiler's last 0.1 of the 1.3: an inliner for the small procedures
17- that are one expression (`Gen.drop`, `X64.mem`, `Chunk.put1`, `Scan.tokPos`)
18- would take call overhead off some 15% of the instructions; `chooseRegs`
19- reads each procedure twice, which is 13% of the time; and `Mem`, `Item`
20- and `Adr` are records copied at each call that passes them on.
21-- A port to aarch64, to measure one: a new `Gen.raz`, an encoder and
22- assembler for it, and its ELF.
23-
24-## Wishes, for a later thaw
25-
26-What the language or the library might have, met while writing raz;
27-none is built while the freeze holds.
28-
29-- **`inline`, a hint** (dropped, 2026-10.13): a hint means nothing a
30- program can see, and this compiler can inline by itself, with no
31- keyword. Measured: `test/bench/Grep` with its helpers inlined by hand
32- ran 30% faster; rat's hot procedures gained nothing from it, but 12%
33- from hoisting two fast paths by hand (`Width.cells`,
34- `Screen.unsplit`), which is an inliner several times the size. Revisit
35- only if more programs show it.
36-- **A `const` parameter.** `proc what(const x: Item): []U8;`: the callee
37- may not change `x` (nor take its address), so the caller may pass the
38- address of a record or array without a copy, and the program means the
39- same. Met in Self step 3b, where the seed's `const x: TItem` (about 130
40- bytes) became a value parameter, copied at every call. Measured in Self
41- step 4: not what stands out, the compiler's profile is flat
42- (`Scan.tokPos` is 9%).

PROPOSALS.md added +16 -0

@@ -0,0 +1,16 @@
1+# raz: proposals
2+
3+What the language or the library might have, met while writing raz.
4+None is built while the freeze holds; each waits for a later thaw, by
5+the owner's word, and goes into the report before any code.
6+
7+## A `const` parameter
8+
9+`proc what(const x: Item): []U8;`: the callee may not change `x` (nor
10+take its address), so the caller may pass the address of a record or
11+array without a copy, and the program means the same.
12+
13+Met in porting the compiler to raz, where the seed's `const x: TItem`
14+(about 130 bytes) became a value parameter, copied at every call.
15+Measured once the port built: not what stands out, the compiler's
16+profile is flat (`Scan.tokPos` is 9%).

README.md (history) modified +2 -2

@@ -47,7 +47,7 @@
4747 | `conform/` | The conformance suite: what every implementation must do |
4848 | `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 |
4949 | `test/` | This compiler's own tests, and the scripts that run them |
50-| `PLAN.md` | The plan: the milestone under way and its steps |
50+| `PROPOSALS.md` | What the language might have, waiting for a later thaw |
5151
5252 ## Building
5353
@@ -223,7 +223,7 @@
223223
224224 Since v0.5.0 the language is frozen, softly: it changes only to mend a
225225 defect, and the library grows only by what breaks no program. Wishes
226-wait on a list in `PLAN.md`, for a later thaw; v0.6.0 was one, for a
226+wait in `PROPOSALS.md`, for a later thaw; v0.6.0 was one, for a
227227 language anyone can build again from its report.
228228
229229 ## Not here

doc/book/PLAN.md deleted +0 -106

@@ -1,106 +0,0 @@
1-# Stage: the book "Compiling Raz"
2-
3-This is the owner's go-ahead for a new stage: a book, "Compiling Raz",
4-explaining how the raz compiler works. Follow CLAUDE.md's way of working:
5-one commit per step, push it, then stop for review. Don't change the
6-language or the compiler for the book's sake. If the book exposes a bug
7-or a clumsy spot, report it rather than fixing it.
8-
9-## Read first
10-- CLAUDE.md, doc/raz.md (the report), doc/compiler.md, README.md.
11-- seed/*.pas, the whole compiler (about 5,000 lines), and enough of lib/
12- (Rt, Heap, Mem, Thread, Sys) to explain the runtime.
13-- The tiza skill, for drawings.
14-
15-## The reader
16-A working programmer: not good at Pascal, little knowledge of compilers.
17-- Assume they roughly know registers, the stack and memory. Explain only
18- what raz does with them (frames, calling convention, layout).
19-- Introduce compiler ideas (tokens, grammar, generating code while
20- parsing, symbol tables) briefly and in friendly terms where they first
21- appear.
22-- Teach just enough Pascal to read the compiler: one early chapter, then
23- more as features come up. Teach enough raz the same way.
24-- Keep the two languages visibly apart: ```raz and ```pascal code blocks,
25- and say which one is on screen.
26-- Don't explain formats that can be looked up. ELF gets a page on what
27- raz writes and why, plus a pointer to the spec.
28-- Target 40-50k words.
29-
30-## Tone
31-Like Learn You a Haskell and Starting FORTH: tiny steps, talking straight
32-to the reader, every idea shown at once on a real example, drawings that
33-carry meaning. Warm, with an occasional dry aside. Never a joke per
34-paragraph; humor is seasoning. Plain, short sentences.
35-
36-## Mascot: Razmataz
37-A small, very serious creature with a flashy name, which suits a frugal
38-compiler (razzmatazz minus one z).
39-- Its motto, "once is enough", plays on "raz" meaning "one" or "once" in
40- Polish and Russian. Check that the compiler really works in one pass
41- before leaning on this; if it doesn't, find the honest version of the
42- joke.
43-- Razmataz appears in tiza drawings: eating characters in the scanner,
44- stacking boxes in frames, throwing unused code overboard in linking.
45-
46-## Structure
47-Build up gradually, not unit by unit:
48-1. Introduction and a whirlwind tour: compile `exit 42` (or the smallest
49- real program) through every stage, shallowly.
50-2. Enough Pascal (and raz) to follow along.
51-3. One chapter per language feature, followed through scanner, parser,
52- symbols, code generator and machine code: variables and expressions,
53- control flow, procedures and frames, records and arrays, pointers and
54- the heap, strings, modules, defer, C interop, threads.
55-4. Closing chapters: x64 encoding, link (tree shaking, layout), elf,
56- speed (how it reaches 400k lines a second), and where to go next.
57-
58-Refine this order in the outline (step 1).
59-
60-## Format and tooling
61-- Markdown in doc/book/: NN-slug.md per chapter, plus metadata.yaml
62- (title, author Luis, cover). It must read well as plain text.
63-- `make book` builds build/compiling-raz.epub with pandoc. If pandoc gets
64- installed locally, update the desktop guide (see the global
65- CLAUDE.md).
66-- Drawings: .tiza source and a rendered PNG, both committed (CI has no
67- tiza). Every image has a caption that stands on its own in plain text.
68- Use ASCII art in code blocks for diagrams that are really structure
69- (frames, memory layout); those read the same in both formats.
70-- Disassembly is cleaned up: instructions only, the raz source line
71- beside them as a comment, and bytes only where the bytes are the point.
72- Show raw objdump output once, early, next to the cleaned version, and
73- say how to get it.
74-- A checker, written in raz alongside tools/Doc.raz (reuse what exists),
75- run by `make check`. It must:
76- - compile and run every raz example marked as runnable and compare the
77- expected output written in the book;
78- - confirm every quoted Pascal excerpt still matches seed/, quoted by
79- unit and routine name, never by line number;
80- - regenerate or verify the cleaned disassembly.
81- The goal: when the compiler changes, `make check` fails rather than
82- the book going quietly wrong.
83-- CI (.github/workflows/): on a push to main that touches doc/book/**,
84- seed/** or lib/**, build the epub and replace the file on a standing
85- prerelease tagged `book` (gh release upload --clobber), so the owner
86- has a fixed URL to open on an iPad. Tagged releases also attach that
87- version's epub.
88-
89-## Steps (each one is a commit, then stop for review)
90-1. The outline: doc/book/OUTLINE.md, chapter by chapter, with what each
91- one teaches, its running example, and the drawings planned.
92-2. The tooling: doc/book/ skeleton, `make book`, the checker in
93- `make check`, the CI job. One placeholder chapter proves the pipeline
94- end to end.
95-3. Razmataz's design sheet (tiza) and one sample chapter, the procedures
96- and frames one, to set tone and depth.
97-4. Then one chapter per step, in order.
98-
99-doc/compiler.md stays as it is: the short guide for people changing the
100-compiler. The book can point to it but never replaces it.
101-
102-## Left to the tooling step
103-- How the checker marks runnable examples and quoted excerpts inside
104- Markdown.
105-- Whether the cleaned disassembly comes from the compiler's own line
106- information (`make gdb` suggests it has some) or from objdump.

doc/compiler.md (history) modified +2 -2

@@ -737,8 +737,8 @@
737737 in `Obj`, a cache of the names found by `chooseRegs`' look-ahead, and
738738 passing `Item` to `adrOf` as a `var` parameter, so as not to copy it.
739739 What is left is spread thinly: the procedure call overhead of many small
740-routines (`Gen.drop`, `X64.mem`, `Chunk.put1`, which an inliner, listed
741-in `PLAN.md`, would remove), the reading of every procedure twice, and
740+routines (`Gen.drop`, `X64.mem`, `Chunk.put1`, which an inliner
741+would remove), the reading of every procedure twice, and
742742 a record parameter copied at each call that passes it on (`Mem`, in the
743743 encoder).
744744

src/README.md (history) modified +1 -2

@@ -1,7 +1,6 @@
11 # src: the compiler in raz
22
33 The port of the Pascal compiler, the **seed** in `../seed/`, to raz.
4-`../PLAN.md`, "Self", says what it is for and the order of its units.
54
65 One module to a seed unit, with the seed's name, written to the same
76 rules: plain code, each module opening with what it is, what it
@@ -137,7 +136,7 @@
137136 same; whether the compiler built from this is slower for it is for
138137 the speed test of step 4 to say. A `const` parameter (a hint that
139138 the callee won't change it, so that the caller may pass its address)
140- would be a language change: it goes on the wish list.
139+ would be a language change: it is in `../PROPOSALS.md`.
141140 - **`Parse` and the seed's jumps.** The seed's `Guard`, `setjmp` and
142141 `longjmp` are `guard`, a record of what to put back, and the `ERROR`
143142 that comes up through `try` to the statement or declaration that is