Docs for v0.20.0: no seed, BOOT, PTR in the tutorial and the tour README, CLAUDE.md, doc/compiler.md and src/README.md say that the release BOOT names builds src/, and that the Pascal seed is in git at v0.19.0; CLAUDE.md's setup list loses make tests and seed-bench and gains prev-bench, and its readings say what src/ may use now and take PTR. The tutorial's section 6 and the tour's lesson 7 show PTR, the tour first with the ADR(s[0]) that stops on "". PROPOSALS.md loses the slice's pointer, done. make dist takes VERSION and make site RELEASES, for releases whose tags aren't pushed yet. HANDOVER.md says what to tag where, and how.
| @@ -8,15 +8,13 @@ | ||
| 8 | 8 | |
| 9 | 9 | ## Setup and checks |
| 10 | 10 | |
| 11 | - apt-get install -y fp-compiler # Free Pascal 3.2.2, if fpc is missing | |
| 12 | - make raz # the compiler, ./raz, built from src/ by the seed; its library is lib/ | |
| 11 | + make raz # the compiler, ./raz, built from src/ by the release BOOT names; its library is lib/ | |
| 13 | 12 | make check # every example and test against its expected output |
| 14 | 13 | make bench # must report at least 400,000 lines a second |
| 15 | - make kernels # test/bench's kernels against FPC -O2's twins | |
| 14 | + make prev-bench # the compiler's speed against BOOT's: more than a tenth slower fails | |
| 15 | + make kernels # test/bench's kernels against FPC -O2's twins (apt-get install -y fp-compiler) | |
| 16 | 16 | make loc # lines of the compiler, by rloc; the last, code, is the budget |
| 17 | - make tests # the small Pascal tests of scan, x64, link and elf | |
| 18 | - make seed-bench # the scanner's and the compiler's speed against the seed's | |
| 19 | - make fixpoint # the seed builds src, that builds src, that again: the last two agree | |
| 17 | + make fixpoint # BOOT's release builds src, that builds src, that again: the last two agree | |
| 20 | 18 | make gdb # gdb stops at a line of a test and names it |
| 21 | 19 | make stress # 40,000 native threads; make check runs a small version |
| 22 | 20 | make alpine # test/libc in an Alpine container, over musl (docker) |
| @@ -49,11 +47,10 @@ | ||
| 49 | 47 | ## How we work |
| 50 | 48 | |
| 51 | 49 | - The compiler, `src/`, is raz, in the language of the report and with |
| 52 | - the library of `lib/`; it must build with the seed (`seed/`, Free | |
| 53 | - Pascal 3.2.2, `{$mode objfpc}{$H-}`: records, pointers, shortstrings; | |
| 54 | - no classes, ansistrings, exceptions, dynamic arrays or SysUtils), so | |
| 55 | - it uses nothing the seed doesn't know until a release makes a new | |
| 56 | - seed. | |
| 50 | + the library of `lib/`; it must build with the release `BOOT` names | |
| 51 | + (v0.19.0), so it, and the modules of `lib/` it imports, use nothing | |
| 52 | + that release doesn't know (`PTR`, report 2026-10.34, not yet) until | |
| 53 | + `BOOT` names a newer one. | |
| 57 | 54 | - Work goes by milestones, each a release, set by the owner. A milestone |
| 58 | 55 | starts only on the owner's explicit go-ahead; within it, one commit |
| 59 | 56 | per step, pushed as it is done, then stop for review. Never start a |
| @@ -70,7 +67,7 @@ | ||
| 70 | 67 | commented throughout, most of all where it is obscure or needs a |
| 71 | 68 | compiler writer's knowledge; at least 400,000 lines of raz a second; |
| 72 | 69 | the report, `doc/raz.md`, under 40 pages as `make pdf` renders it, |
| 73 | - checked by hand after each milestone (31 at report 2026-10.32). | |
| 70 | + checked by hand after each milestone (32 at report 2026-10.34). | |
| 74 | 71 | - Clarity comes first, before speed and size: the compiler must be a |
| 75 | 72 | model of plain code that a beginner can follow. Every rewrite of the |
| 76 | 73 | code it makes is explained where it is done, with the code before |
| @@ -83,15 +80,20 @@ | ||
| 83 | 80 | |
| 84 | 81 | ## Where things stand |
| 85 | 82 | |
| 86 | -v0.19.0, report 2026-10.33, is the latest release: the ninth thaw, a | |
| 87 | -`const` parameter, a variant in a constant, and the library taking | |
| 88 | -`var`, `const` or a value where it took a pointer (`Arena`, `Buf`, | |
| 89 | -`Files`, `Fmt`, `List`, `Lock`, `Map`, `Opt`, `Str`, `Sys`'s | |
| 90 | -directories, `Thread`'s `Mutex`, `Vec`; and `tools/Scan.raz`), which | |
| 91 | -breaks calls written with `ADR`; the compiler's message names the | |
| 92 | -mending. Next: v0.20.0, built by v0.19.0, drops the Pascal seed; then | |
| 93 | -`Buf.bytes`, `Sys.entryKind` and `src/`'s records only read take | |
| 94 | -`const`. | |
| 83 | +v0.20.0, report 2026-10.34, is made and not yet tagged: v0.19.0 builds | |
| 84 | +`src/` (`BOOT`) and the Pascal seed is gone; `Buf.bytes`, | |
| 85 | +`Sys.entryKind` and `src/`'s `Item`s only read take `const`; and the | |
| 86 | +tenth thaw, by the owner's word, `PTR(s)`, a slice's pointer, with | |
| 87 | +messages that point to it. Its tag, and v0.18.1's and v0.19.0's, which | |
| 88 | +were never pushed, are the owner's: `HANDOVER.md` says what to tag | |
| 89 | +where and how, and what comes next (`Sys`'s private `bytes` gives way | |
| 90 | +to `PTR` once `BOOT` names v0.20.0). | |
| 91 | +v0.19.0, report 2026-10.33, before it: the ninth thaw, a `const` | |
| 92 | +parameter, a variant in a constant, and the library taking `var`, | |
| 93 | +`const` or a value where it took a pointer (`Arena`, `Buf`, `Files`, | |
| 94 | +`Fmt`, `List`, `Lock`, `Map`, `Opt`, `Str`, `Sys`'s directories, | |
| 95 | +`Thread`'s `Mutex`, `Vec`; and `tools/Scan.raz`), which breaks calls | |
| 96 | +written with `ADR`; the compiler's message names the mending. | |
| 95 | 97 | v0.18.1, report 2026-10.32, before it: v0.18.0's thaw (a |
| 96 | 98 | constant typed `[]T` may be `[]`, the empty slice, as may a constant's |
| 97 | 99 | slice part), with `Vec.pop` and `Sys.Info.links`, and a constant's |
| @@ -103,10 +105,10 @@ | ||
| 103 | 105 | v0.17.0's thaw before it: `INT` at least 16 bits, and `U8`, `I8` and |
| 104 | 106 | `I16` widening to it; an enumeration's name written with its type, and |
| 105 | 107 | shared; `continue`; `[]` as the empty slice; `Width`. `src/` is the |
| 106 | -compiler in raz, built by itself (Self, done); the seed in `seed/` is | |
| 107 | -frozen, and v0.9.1 was the last release it built. The compiler takes | |
| 108 | -1.4 times the Pascal one's time; `make kernels` measures `test/bench` | |
| 109 | -against FPC `-O2`. What | |
| 108 | +compiler in raz, built by itself (Self, done); the Pascal seed, the | |
| 109 | +release compiler to v0.9.1 and what built `src/` to v0.19.0, is in git | |
| 110 | +at v0.19.0. The compiler takes 1.4 times the Pascal one's time; `make | |
| 111 | +kernels` measures `test/bench` against FPC `-O2`. What | |
| 110 | 112 | each version of the report changed is in `doc/report-history.md`, and |
| 111 | 113 | what each step did is in git; don't repeat it here. |
| 112 | 114 | |
| @@ -120,8 +122,8 @@ | ||
| 120 | 122 | for it. A wish for more, the owner's or yours, goes in |
| 121 | 123 | `PROPOSALS.md`, for a later thaw; it isn't built. Thaws happen only by the |
| 122 | 124 | owner's word (v0.6.0, reports 2026-10.13 to 10.23, 10.25 for strings, |
| 123 | -10.26 for `INT` and views, and 10.33 for `const` parameters, variants | |
| 124 | -in constants and the library by `var`). | |
| 125 | +10.26 for `INT` and views, 10.33 for `const` parameters, variants | |
| 126 | +in constants and the library by `var`, and 10.34 for `PTR`). | |
| 125 | 127 | |
| 126 | 128 | **The reserved words and the module names are settled.** That a word |
| 127 | 129 | is reserved, however common (`code`, `to`, `packed`, `forward`, `set`, |
| @@ -142,7 +144,9 @@ | ||
| 142 | 144 | describe` (`build/version.inc`, made by `make`). Pushing the tag runs |
| 143 | 145 | `.github/workflows/ci.yml`, which checks it and makes the GitHub |
| 144 | 146 | release with a tarball of `raz` and `lib/`; it also checks every push |
| 145 | -to `main`. `README.md`'s "Versions" gives the commands. v0.3.0 is | |
| 147 | +to `main`. A release whose tag isn't pushed yet goes to the website | |
| 148 | +by `make site RELEASES="vX.Y.Z=COMMIT"`, its tarball made by `make | |
| 149 | +dist REV=COMMIT VERSION=X.Y.Z`, the same as the tag's will be. `README.md`'s "Versions" gives the commands. v0.3.0 is | |
| 146 | 150 | the first. The tarball has `tools/`, which the website offers from |
| 147 | 151 | 0.7.1 on. |
| 148 | 152 | |
| @@ -154,16 +158,21 @@ | ||
| 154 | 158 | by hand. A test or example without `.expect` is only |
| 155 | 159 | compiled (`examples/Window.raz` needs a display). |
| 156 | 160 | |
| 157 | -## The compiler and the seed | |
| 161 | +## The compiler and BOOT | |
| 158 | 162 | |
| 159 | -`src/` is the compiler, in raz: one module to a | |
| 160 | -seed unit, the same names. `seed/`, the Free Pascal compiler it was | |
| 161 | -ported from, is the **seed**: frozen at its last version, kept to build | |
| 162 | -`src/` the first time (`make raz`, `make fixpoint`), and to be dropped | |
| 163 | -in time. `src/` is no longer tested against it unit by unit (the owner | |
| 164 | -dropped `seed-check` after v0.17.0): `make check`, the fixpoint and | |
| 165 | -`conform/` are its tests. Never edit the seed; a difference | |
| 166 | -found is told to the owner. | |
| 163 | +`src/` is the compiler, in raz: one module to a unit of the Pascal | |
| 164 | +compiler it was ported from, the same names. The release `BOOT` names, | |
| 165 | +by its tag and its tarball's SHA-256, builds it: `src/boot.sh` fetches | |
| 166 | +the tarball into `build/boot/` (curl, or `gh api` for a private | |
| 167 | +repository: CI gives it `GH_TOKEN`), checks the sum and puts its `raz` | |
| 168 | +there with today's `lib/` beside it. Each release is built by the one | |
| 169 | +before it, back to v0.19.0, which the Pascal seed built; the seed is in | |
| 170 | +git at v0.19.0 (`seed/`), and a comment in `src/` that names "the | |
| 171 | +seed" means it. `make check`, the fixpoint and `conform/` are the | |
| 172 | +compiler's tests. Moving `BOOT` to a newer release, once its tag is | |
| 173 | +pushed and CI's tarball has the SHA-256 `make dist` gives here, is a | |
| 174 | +step of its own, by the owner's word; then `src/` may use what that | |
| 175 | +release brought. `fpc` is needed only for `make kernels`' Pascal twins. | |
| 167 | 176 | |
| 168 | 177 | `sbcl/` is an example, not part of the build: a second compiler, in |
| 169 | 178 | Common Lisp, written from the report alone and kept as a reference |
| @@ -203,8 +212,9 @@ | ||
| 203 | 212 | in `link static;` is not a reserved word. It is linked against |
| 204 | 213 | glibc, or musl (`/lib/ld-musl-x86_64.so.1`, needing `libc.so`) by |
| 205 | 214 | `-libc musl` or on a machine with musl's loader and not glibc's. |
| 206 | - `lib/Sys.raz` and `CAbi` are read by the seed for the interface | |
| 207 | - check, so they keep to the seed's language. | |
| 215 | + `lib/Sys.raz` and `CAbi` are read for the interface check when | |
| 216 | + BOOT's release builds `src/`, so they keep to its language, as the | |
| 217 | + modules `src/` imports do. | |
| 208 | 218 | - `Sys` gives minus Linux's errnos on every target; `Sys.raz` maps the |
| 209 | 219 | C library's through `CAbi.errnos`. |
| 210 | 220 | - C symbols are reached through quadwords the loader fills in |
| @@ -244,9 +254,9 @@ | ||
| 244 | 254 | copied. A variable kept in a register goes to memory for it, as for |
| 245 | 255 | `ADR`. Another module's variable may be viewed, and not written. A |
| 246 | 256 | view that runs past its end fails as kind 7 of `Rt.fail`. `src/`, |
| 247 | - and the library it imports (`Str`, `Bytes`, ...), use neither views | |
| 248 | - nor the widening of 2026-10.26, since the seed builds them, until a | |
| 249 | - release makes a new seed. | |
| 257 | + and the library it imports (`Str`, `Bytes`, `Sys`, ...), may use | |
| 258 | + views and the widening now that v0.19.0 builds them; they use | |
| 259 | + neither yet. | |
| 250 | 260 | - A returned slice of the frame (report 2026-10.27, 7.3) is caught by |
| 251 | 261 | `Item.frame`, which sees only the expression: a slice held first in a |
| 252 | 262 | local slice variable or a record, stored, or come back from a call, |
| @@ -295,9 +305,20 @@ | ||
| 295 | 305 | - A variant in a constant must be typed; `const D = dot;` is an error |
| 296 | 306 | that says to write its type. Its case is read by name (`constCase`). |
| 297 | 307 | - The library takes a `var` for what it changes and `const` for a record |
| 298 | - or array it only reads (report 2026-10.33), but in the modules the | |
| 299 | - seed compiles (`Buf`, `Sys`, ...), which take a value or `var` there | |
| 300 | - until the seed is gone. Measured: a `Map` passed as a value, four | |
| 308 | + or array it only reads (report 2026-10.33); `Buf.bytes` and | |
| 309 | + `Sys.entryKind` came to it in v0.20.0, with the seed gone. `src/` | |
| 310 | + takes an `Item` as `const` only where callgrind counts a gain, on the | |
| 311 | + paths every compile goes through; the routines that word an error | |
| 312 | + take a value. Measured: a `Map` passed as a value, four | |
| 301 | 313 | words, made a loop of `get` half again as slow as `const`. A trace |
| 302 | 314 | shows no `var` or `const` parameter. `Fmt`'s `format` and `put` keep |
| 303 | 315 | `^Buf.Buf`, since `nil` is standard output there. |
| 316 | +- `PTR(s)` (report 2026-10.34) is a slice's first word, read with no | |
| 317 | + check; of an array or a string constant, its address, refused wherever | |
| 318 | + a slice of all of it is (a packed record's misaligned field, a view, | |
| 319 | + through `^VOLATILE`, another module's array). `PTR("")` is the | |
| 320 | + string's place in read-only data, not `nil`; an empty slice cut from | |
| 321 | + another keeps its place. `PTR([])` is an error, since `[]` has no | |
| 322 | + type there, and its help says it would be `nil`. A slice where its | |
| 323 | + element's pointer is wanted, and a pointer where a slice is, are | |
| 324 | + errors whose help names `PTR(s)` and `LEN(s)`, or `p[0..n]`. |
| @@ -1,300 +1,95 @@ | ||
| 1 | 1 | # Handover, 2026-10-17 |
| 2 | 2 | |
| 3 | -Where the work stands, what to tag where, and how to go on. Delete this | |
| 4 | -file once v0.20.0 is out. | |
| 3 | +v0.20.0 is done on `main`; nothing is tagged. This says what to tag | |
| 4 | +where, how, and what to check. Delete this file once the three tags | |
| 5 | +below are pushed and their releases checked. | |
| 5 | 6 | |
| 6 | 7 | ## What to tag |
| 7 | 8 | |
| 8 | -This session could push to `main` but not tags (the environment's git | |
| 9 | -proxy refused them, 403), so the tags are the owner's to add, | |
| 10 | -retrospectively. Each is an annotated tag whose message is what | |
| 11 | -`raz --version` prints; pushing it runs CI, which checks the commit and | |
| 12 | -makes the GitHub release with its tarball. | |
| 9 | +These sessions can push to `main` but not tags, so the tags are the | |
| 10 | +owner's to add. Each is an annotated tag whose message is what | |
| 11 | +`raz --version` prints at that commit; pushing it runs | |
| 12 | +`.github/workflows/ci.yml`, which checks the commit and makes the | |
| 13 | +GitHub release with its tarball. Tag in this order, oldest first, and | |
| 14 | +push them one at a time, since each release's CI builds `src/` with | |
| 15 | +the release `BOOT` names, which must exist first: | |
| 13 | 16 | |
| 14 | -| Tag | Commit | Message | Note | | |
| 17 | +| Tag | Commit | Message | Tarball's SHA-256 | | |
| 15 | 18 | |---|---|---|---| |
| 16 | -| `v0.18.1` | `88b18ba` ("Docs for v0.18.1") | `raz 0.18.1, report 2026-10.32` | Never tagged, though CLAUDE.md and README call it a release; `1328b81` ("site: v0.18.1") follows it. Check the commit before tagging. | | |
| 17 | -| `v0.19.0` | `51a90a6` | `raz 0.19.0, report 2026-10.33` | Its tarball's SHA-256 is `217448cb6521c76a28d71499d70a5dfdebc2dbcbc81d6d41ed9d9590005772ed` (made here by `make dist REV=v0.19.0`). | | |
| 19 | +| `v0.18.1` | `88b18ba` ("Docs for v0.18.1: ...") | `raz 0.18.1, report 2026-10.32` | what `site/public/download/raz-0.18.1-linux-x86_64.tar.gz.sha256` says | | |
| 20 | +| `v0.19.0` | `51a90a6` ("Report 2026-10.33 is followed; ...") | `raz 0.19.0, report 2026-10.33` | `217448cb6521c76a28d71499d70a5dfdebc2dbcbc81d6d41ed9d9590005772ed` | | |
| 21 | +| `v0.20.0` | the commit "Docs for v0.20.0" (see below) | `raz 0.20.0, report 2026-10.34` | what `site/public/download/raz-0.20.0-linux-x86_64.tar.gz.sha256` says | | |
| 18 | 22 | |
| 19 | 23 | git tag -a v0.18.1 -m 'raz 0.18.1, report 2026-10.32' 88b18ba |
| 24 | + git push origin v0.18.1 | |
| 20 | 25 | git tag -a v0.19.0 -m 'raz 0.19.0, report 2026-10.33' 51a90a6 |
| 21 | - git push origin v0.18.1 v0.19.0 | |
| 26 | + git push origin v0.19.0 | |
| 27 | + # wait for v0.19.0's release (Actions, "ci"), and check its sum: | |
| 28 | + # gh api repos/ldiaz94/raz/releases/tags/v0.19.0 --jq '.assets[].name' | |
| 29 | + # gh release download v0.19.0 -p '*.tar.gz' && sha256sum raz-0.19.0-*.tar.gz | |
| 30 | + # it must be BOOT's; only then: | |
| 31 | + git tag -a v0.20.0 -m 'raz 0.20.0, report 2026-10.34' <commit> | |
| 32 | + git push origin v0.20.0 | |
| 22 | 33 | |
| 23 | -Tarballs are the same byte for byte wherever they are made: v0.18.0's, | |
| 24 | -made here, has GitHub's SHA-256 (`d05f2adb...`). So CI's v0.19.0 | |
| 25 | -tarball should have the sum above; check it (`gh api | |
| 26 | -repos/ldiaz94/raz/releases/tags/v0.19.0`, then the asset) before going | |
| 27 | -on, since v0.20.0 pins it. | |
| 34 | +`<commit>` is the commit whose subject is "Docs for v0.20.0", found by | |
| 35 | +`git log --oneline --grep='^Docs for v0.20.0'`; it is the one before | |
| 36 | +"site: v0.19.0 and v0.20.0". Check before tagging that `make check` | |
| 37 | +passes there, and that `src/Raz.raz` there says report 2026-10.34. | |
| 38 | +The site commit after it changes only | |
| 39 | +`site/` and this file, so the tag stays on the docs commit, as v0.18.1's | |
| 40 | +did. | |
| 28 | 41 | |
| 29 | -## What is done (on `main`) | |
| 30 | - | |
| 31 | -v0.19.0, report 2026-10.33, the ninth thaw, by the owner's word: a | |
| 32 | -`const` parameter, a variant in a constant, and the library taking | |
| 33 | -`var`, `const` or a value where it took a pointer. Commits `71db16c` | |
| 34 | -(report) to `51a90a6` (docs; the compiler follows 10.33), then | |
| 35 | -`d704863` (PROPOSALS.md: the done parts out; `[]const T` in). Each | |
| 36 | -commit passed `make check`; the fixpoint, `stress`, `kernels` and | |
| 37 | -`tests` passed at the end. Notes: | |
| 38 | - | |
| 39 | -- `bench` dipped below 400,000 lines a second on some runs in this | |
| 40 | - container; the new compiler was about 9% faster than the one before | |
| 41 | - the work on the same machine, so it is the machine's load. | |
| 42 | -- Measured: `Map.get` and `Vec.all` taking their record as a value made | |
| 43 | - a loop half again as slow; as `const` the code is the pointer's, so | |
| 44 | - they take `const`. `Buf.bytes` (a value) and `Sys.entryKind` (`var`) | |
| 45 | - wait for v0.20.0, since the seed compiles them and doesn't know | |
| 46 | - `const`. | |
| 47 | -- A trace no longer shows `var` or `const` parameters (four `.stderr` | |
| 48 | - files regenerated). | |
| 49 | -- The report is about 32 pages of 40 by its words; this container's | |
| 50 | - pandoc is too old for `make pdf`. Check it by hand. | |
| 42 | +Before v0.19.0's release exists, CI on every push to `main` fails at | |
| 43 | +`src/boot.sh` (it can't fetch the tarball `BOOT` names); that is | |
| 44 | +expected, and goes once the tag is pushed. v0.18.1 and v0.19.0 were | |
| 45 | +built by the Pascal seed, so their CI installs `fp-compiler` (their | |
| 46 | +own `ci.yml` says so). | |
| 51 | 47 | |
| 52 | -## v0.20.0: what is left | |
| 48 | +## Why the sums can be trusted | |
| 53 | 49 | |
| 54 | -The plan, approved: v0.19.0 builds `src/`, the Pascal seed goes, then | |
| 55 | -what waited for that. | |
| 50 | +`make dist` makes the same tarball, byte for byte, wherever it runs. | |
| 51 | +Without the tags, the tarballs here were made with the version given | |
| 52 | +by hand: v0.19.0's by building `51a90a6` in `/tmp/raz-dist` with | |
| 53 | +`build/version.inc` set to `'0.19.0'` (its Makefile predates | |
| 54 | +`VERSION`), which gave BOOT's sum, the same that the session before | |
| 55 | +got with a local tag; v0.20.0's by `make dist REV=<commit> | |
| 56 | +VERSION=0.20.0`, which the Makefile now takes for this. So CI's | |
| 57 | +tarball for each tag must have the sum in the table; if one differs, | |
| 58 | +the website's copy is wrong and must be replaced by CI's before | |
| 59 | +anyone pins it (the site keeps a tarball once it has it). | |
| 56 | 60 | |
| 57 | -1. **Build from v0.19.0; drop the seed** (started here, not committed; | |
| 58 | - see below). Needs the v0.19.0 release to exist, for CI. | |
| 59 | -2. **`Buf.bytes` and `Sys.entryKind` take `const`** (both `Sys` | |
| 60 | - files), with volume 2 and `test/doc`. No caller changes. | |
| 61 | -3. **`src/`'s records only read take `const`** (`Item`, about 130 | |
| 62 | - bytes, in `Item.what`, `adrOf`, `realOf`, `discard` and the like), | |
| 63 | - kept only where `make bench` gains. | |
| 64 | -4. Docs: README (building, "What's here", the seed), CLAUDE.md (the | |
| 65 | - setup list loses `make tests` and `seed-bench`, gains `prev-bench`; | |
| 66 | - "The compiler and the seed"; the readings that keep `Sys.raz`, | |
| 67 | - `CAbi`, `src/` and its library to the seed's language, and that say | |
| 68 | - views and the widening wait for a new seed), `doc/compiler.md`'s | |
| 69 | - opening, `src/README.md`, and comments in `src/*.raz` that name the | |
| 70 | - seed. `fpc` stays only for `make kernels`' Pascal twins. | |
| 71 | -5. Tag `v0.20.0` (`raz 0.20.0, report 2026-10.33`). | |
| 61 | +## What v0.20.0 did | |
| 72 | 62 | |
| 73 | -Also waiting, not started: `PTR(s)` in PROPOSALS.md, which the owner | |
| 74 | -thought worth doing; it is a library/built-in addition that breaks no | |
| 75 | -program. | |
| 63 | +- v0.19.0 builds `src/` (`BOOT`, `src/boot.sh`); the Pascal seed and | |
| 64 | + its tests (`make tests`, `seed-bench`) went; `make prev-bench` | |
| 65 | + compares this compiler with BOOT's. CI needs no `fp-compiler`. | |
| 66 | +- `Buf.bytes` and `Sys.entryKind` take `const`. | |
| 67 | +- `src/`'s `Item`s only read take `const` where callgrind counts a | |
| 68 | + gain (16 routines, 0.4% of the instructions); the 11 that word an | |
| 69 | + error keep a value. | |
| 70 | +- Report 2026-10.34, the tenth thaw, by the owner's word: `PTR(s)`, the | |
| 71 | + address a slice starts at, unchecked, so an empty slice gives what it | |
| 72 | + holds. The compiler's messages point to it (a slice where a pointer | |
| 73 | + is wanted says `PTR(s)` and `LEN(s)`). `conform/` has `Ptr` and ten | |
| 74 | + errors; the tutorial (section 6) and the tour (lesson 7, "A slice's | |
| 75 | + pointer") show it; raz(7), the editors, README, CLAUDE.md and | |
| 76 | + `doc/compiler.md` say it. | |
| 77 | +- `make dist` and `make site` take releases not tagged yet (`VERSION`, | |
| 78 | + `RELEASES`); the website offers 0.19.0 and 0.20.0. | |
| 76 | 79 | |
| 77 | -## Step 1 as it was left | |
| 80 | +Each commit passed `make check`; the fixpoint, `bench`, `prev-bench` | |
| 81 | +and `fmt` passed at the end. The report is 32 pages by `make pdf` | |
| 82 | +(pandoc 3.8 and Chromium; this container's pandoc, 3.1.3, is too old, | |
| 83 | +so a newer one was fetched into the session's scratch space). | |
| 78 | 84 | |
| 79 | -Committed on the branch `wip/v0.20-boot` (`849d93e`), not on `main`, | |
| 80 | -since CI on `main` would fail until the v0.19.0 release exists; it is | |
| 81 | -repeated here too. Untested | |
| 82 | -beyond `make raz` (which built `raz 0.19.0-1-...` from build/boot/raz). | |
| 85 | +## What comes next | |
| 83 | 86 | |
| 84 | -- `BOOT`, one line: `v0.19.0 217448cb6521c76a28d71499d70a5dfdebc2dbcbc81d6d41ed9d9590005772ed` | |
| 85 | -- `src/boot.sh`, executable: fetches the tarball BOOT names into | |
| 86 | - `build/boot/` (curl for a public repository; `gh api` REST for this | |
| 87 | - private one: GraphQL, which `gh release download` uses, is refused | |
| 88 | - from these sessions), checks its SHA-256, puts its `raz` at | |
| 89 | - `build/boot/raz` with `ln -sfn ../../lib build/boot/lib`. CI's check | |
| 90 | - step then needs `GH_TOKEN: ${{ github.token }}` in its env, and no | |
| 91 | - longer needs `fp-compiler`. | |
| 92 | -- `git rm -r seed test/scantest.pas test/enctest.pas test/handtest.pas | |
| 93 | - src/test/ScanBench.pas src/test/ScanBench.raz`. | |
| 94 | -- The Makefile, `src/fixpoint.sh` (stage 0 is `build/boot/raz`) and | |
| 95 | - `src/bench.sh` (now `make prev-bench`: this compiler against BOOT's, | |
| 96 | - failing if more than a tenth slower), as in this diff: | |
| 87 | +Not started; each the owner's call. | |
| 97 | 88 | |
| 98 | -``` | |
| 99 | -diff --git a/Makefile b/Makefile | |
| 100 | -index cad4c6d..6a20acd 100644 | |
| 101 | ---- a/Makefile | |
| 102 | -+++ b/Makefile | |
| 103 | -@@ -1,19 +1,15 @@ | |
| 104 | - # Builds the compiler, raz, from src/ into the repository's root; the | |
| 105 | --# library it needs is lib/, beside it. The seed, the Pascal compiler in | |
| 106 | --# seed/, builds it: fpc makes the seed in build/seed/ (with lib/ beside | |
| 107 | --# it, as every raz has), and the seed compiles src/. The one module | |
| 108 | --# the build makes, Version, holds what git says the version is. | |
| 109 | -+# library it needs is lib/, beside it. The previous release builds it: | |
| 110 | -+# BOOT names that release and its tarball's SHA-256, and src/boot.sh | |
| 111 | -+# puts its raz in build/boot/, with this lib/ beside it (as every raz | |
| 112 | -+# has its library), so that src/ is built against today's library. The | |
| 113 | -+# one module the build makes, Version, holds what git says the version is. | |
| 114 | - | |
| 115 | --FPC = fpc | |
| 116 | --FPCFLAGS = -O2 -Mobjfpc -Sh- -vew -FUbuild | |
| 117 | -+raz: build/boot/raz src/*.raz build/src/Version.raz | |
| 118 | -+ build/boot/raz -Werror -I src -I build/src -o raz src/Raz.raz | |
| 119 | - | |
| 120 | --raz: build/seed/raz src/*.raz build/src/Version.raz | |
| 121 | -- build/seed/raz -Werror -I src -I build/src -o raz src/Raz.raz | |
| 122 | -- | |
| 123 | --build/seed/raz: seed/*.pas build/version.inc | build | |
| 124 | -- mkdir -p build/seed | |
| 125 | -- $(FPC) $(FPCFLAGS) -Fibuild -FEbuild/seed -obuild/seed/raz seed/raz.pas | |
| 126 | -- ln -sfn ../../lib build/seed/lib | |
| 127 | -+build/boot/raz: BOOT src/boot.sh | build | |
| 128 | -+ src/boot.sh | |
| 129 | - | |
| 130 | - build/src/Version.raz: build/version.inc | build | |
| 131 | - mkdir -p build/src | |
| 132 | -@@ -27,16 +23,6 @@ build/version.inc: FORCE | build | |
| 133 | - | |
| 134 | - FORCE: | |
| 135 | - | |
| 136 | --units: seed/*.pas | build | |
| 137 | -- for u in diag scan sym chunk x64 link elf; do $(FPC) $(FPCFLAGS) seed/$$u.pas || exit 1; done | |
| 138 | -- | |
| 139 | --# tests of the parts below the parser, built from test/ | |
| 140 | --tests: units | |
| 141 | -- $(FPC) $(FPCFLAGS) -Fuseed -obuild/scantest test/scantest.pas | |
| 142 | -- $(FPC) $(FPCFLAGS) -Fuseed -obuild/enctest test/enctest.pas | |
| 143 | -- $(FPC) $(FPCFLAGS) -Fuseed -obuild/handtest test/handtest.pas | |
| 144 | -- build/handtest build/hand && build/hand; test $$? = 42 | |
| 145 | -- | |
| 146 | - build: | |
| 147 | - mkdir -p build | |
| 148 | - | |
| 149 | -@@ -47,12 +33,13 @@ clean: | |
| 150 | - check: raz build/raz-lib.3 | |
| 151 | - test/check.sh | |
| 152 | - | |
| 153 | --# the scanner's and the compiler's speed against the seed's | |
| 154 | --seed-bench: raz | build | |
| 155 | -+# the compiler's speed against the previous release's, BOOT's, on the | |
| 156 | -+# same program: fails if this one is more than a tenth slower | |
| 157 | -+prev-bench: raz | build | |
| 158 | - src/bench.sh | |
| 159 | - | |
| 160 | --# the seed builds src/, that builds src/, that builds it again: the | |
| 161 | --# last two must be the same file; check and bench then run on it | |
| 162 | -+# the previous release builds src/, that builds src/, that builds it | |
| 163 | -+# again: the last two must be the same file; check and bench then run on it | |
| 164 | - fixpoint: raz | build | |
| 165 | - src/fixpoint.sh | |
| 166 | - | |
| 167 | -@@ -185,4 +172,4 @@ dist: | |
| 168 | - site: raz pdf | |
| 169 | - python3 site/build.py | |
| 170 | - | |
| 171 | --.PHONY: units tests seed-bench fixpoint check gdb bench kernels stress alpine fmt loc man pdf dist site clean install uninstall | |
| 172 | -+.PHONY: prev-bench fixpoint check gdb bench kernels stress alpine fmt loc man pdf dist site clean install uninstall | |
| 173 | -diff --git a/src/bench.sh b/src/bench.sh | |
| 174 | -index 5d211f3..385050d 100755 | |
| 175 | ---- a/src/bench.sh | |
| 176 | -+++ b/src/bench.sh | |
| 177 | -@@ -1,35 +1,25 @@ | |
| 178 | - #!/bin/sh | |
| 179 | --# The scanner's speed against the seed's, on the compiler's own | |
| 180 | --# benchmark program: the best of seven runs of each. Run from the | |
| 181 | --# repository root, after make raz. | |
| 182 | -+# The compiler's speed against the previous release's, the one BOOT | |
| 183 | -+# names (build/boot/raz), on the same generated program: the best of | |
| 184 | -+# five runs of each, as build/cmp/raz, which finds the library beside | |
| 185 | -+# it. A regression test: it fails if this compiler takes more than a | |
| 186 | -+# tenth longer. Run from the repository root, after make raz. | |
| 187 | - set -e | |
| 188 | --b=build/src | |
| 189 | --mkdir -p $b | |
| 190 | --python3 test/genbench.py 12000 >$b/Bench.raz | |
| 191 | --fpc -O2 -Mobjfpc -Sh- -vew -FUbuild -Fuseed -o$b/scanbench.seed src/test/ScanBench.pas >/dev/null | |
| 192 | --./raz -Werror -I src -o $b/scanbench.src src/test/ScanBench.raz | |
| 193 | --echo "$(wc -l <$b/Bench.raz) lines" | |
| 194 | --for t in seed src; do | |
| 195 | -- best=0 | |
| 196 | -- for i in 1 2 3 4 5 6 7; do | |
| 197 | -- s=$(date +%s%N); $b/scanbench.$t $b/Bench.raz >/dev/null; e=$(date +%s%N) | |
| 198 | -- d=$(( (e - s) / 1000000 )); if [ $best = 0 ] || [ $d -lt $best ]; then best=$d; fi | |
| 199 | -- done | |
| 200 | -- echo "$t: $best ms" | |
| 201 | --done | |
| 202 | -- | |
| 203 | --# The whole compiler's speed, the seed's and this one's, on the same | |
| 204 | --# program: the best of five runs of each, as build/cmp/raz, which finds | |
| 205 | --# the library beside it. | |
| 206 | - mkdir -p build/cmp/bench | |
| 207 | - ln -sfn ../../lib build/cmp/lib | |
| 208 | --cp $b/Bench.raz build/cmp/bench/Bench.raz | |
| 209 | --for t in seed src; do | |
| 210 | -- if [ $t = seed ]; then cp build/seed/raz build/cmp/raz; else cp $b/raz.src build/cmp/raz; fi | |
| 211 | -+python3 test/genbench.py 12000 >build/cmp/bench/Bench.raz | |
| 212 | -+echo "$(wc -l <build/cmp/bench/Bench.raz) lines" | |
| 213 | -+for t in prev this; do | |
| 214 | -+ if [ $t = prev ]; then cp build/boot/raz build/cmp/raz; else cp raz build/cmp/raz; fi | |
| 215 | - best=0 | |
| 216 | - for i in 1 2 3 4 5; do | |
| 217 | - s=$(date +%s%N); build/cmp/raz -o build/cmp/bench/Bench.$t build/cmp/bench/Bench.raz; e=$(date +%s%N) | |
| 218 | - d=$(( (e - s) / 1000000 )); if [ $best = 0 ] || [ $d -lt $best ]; then best=$d; fi | |
| 219 | - done | |
| 220 | -- echo "compile, $t: $best ms" | |
| 221 | -+ echo "$t: $best ms" | |
| 222 | -+ eval "ms_$t=$best" | |
| 223 | - done | |
| 224 | -+if [ $((ms_this * 10)) -gt $((ms_prev * 11)) ]; then | |
| 225 | -+ echo "slower than the previous release, $(cut -d" " -f1 BOOT), by more than a tenth" | |
| 226 | -+ exit 1 | |
| 227 | -+fi | |
| 228 | -diff --git a/src/fixpoint.sh b/src/fixpoint.sh | |
| 229 | -index 5375bc0..8ace35a 100755 | |
| 230 | ---- a/src/fixpoint.sh | |
| 231 | -+++ b/src/fixpoint.sh | |
| 232 | -@@ -1,19 +1,20 @@ | |
| 233 | - #!/bin/sh | |
| 234 | --# The fixpoint: the seed builds src/ (stage 1), that builds src/ | |
| 235 | --# (stage 2), that builds it again (stage 3), and stages 2 and 3 must | |
| 236 | --# be the same file. A program holds the paths it was made from, so each | |
| 237 | -+# The fixpoint: the previous release, BOOT's, builds src/ (stage 1), | |
| 238 | -+# that builds src/ (stage 2), that builds it again (stage 3), and | |
| 239 | -+# stages 2 and 3 must be the same file. A program holds the paths it was made from, so each | |
| 240 | - # stage is built by the same command in the same place, from the | |
| 241 | - # compiler before it copied to build/fix/raz. Run from the repository | |
| 242 | - # root, after `make raz`. Then stage 3 stands in for ./raz (messages name | |
| 243 | - # the library by its path from the compiler, so it must be at the root) | |
| 244 | --# while `make check` and `make bench` run on it; the seed's comes back. | |
| 245 | -+# while `make check` and `make bench` run on it; the one make built | |
| 246 | -+# comes back. | |
| 247 | - set -e | |
| 248 | - d=build/fix | |
| 249 | - rm -rf $d | |
| 250 | - mkdir -p $d/v | |
| 251 | - ln -s ../../lib $d/lib | |
| 252 | - printf 'module Version;\nconst Text* = "%s";\nend Version.\n' "$(tr -d "'" < build/version.inc)" >$d/v/Version.raz | |
| 253 | --cp build/seed/raz $d/stage0 | |
| 254 | -+cp build/boot/raz $d/stage0 | |
| 255 | - for n in 1 2 3; do | |
| 256 | - cp $d/stage$((n - 1)) $d/raz | |
| 257 | - $d/raz -Werror -I src -I $d/v -o $d/stage$n src/Raz.raz | |
| 258 | -``` | |
| 259 | - | |
| 260 | -and `src/boot.sh`: | |
| 261 | - | |
| 262 | -``` | |
| 263 | -#!/bin/sh | |
| 264 | -# The compiler that builds src/: the release BOOT names, by its tag and | |
| 265 | -# its tarball's SHA-256. A release's tarball is the same, byte for byte, | |
| 266 | -# wherever it is made (the Makefile's dist), so the sum pins the very | |
| 267 | -# compiler; and since that release was built by the one before it, back | |
| 268 | -# to v0.19.0, which the Pascal seed built (git has it at that tag), | |
| 269 | -# raz can always be built again from source alone. | |
| 270 | -# | |
| 271 | -# The tarball is taken from build/boot/ if it is there; else from the | |
| 272 | -# GitHub release, by curl, or by gh's REST API where the repository is | |
| 273 | -# private and gh has a token; a machine with no network has it put | |
| 274 | -# there by hand. Its raz goes to build/boot/raz, with this repository's | |
| 275 | -# lib/ beside it, since src/ is built against today's library. Run from | |
| 276 | -# the repository root, by make. | |
| 277 | -set -e | |
| 278 | -read tag sum < BOOT | |
| 279 | -v=${tag#v} | |
| 280 | -t=raz-$v-linux-x86_64.tar.gz | |
| 281 | -d=build/boot | |
| 282 | -repo=ldiaz94/raz | |
| 283 | -mkdir -p $d | |
| 284 | -if [ ! -f $d/$t ]; then | |
| 285 | - if ! curl -fsSL -o $d/$t https://github.com/$repo/releases/download/$tag/$t 2>/dev/null; then | |
| 286 | - id=$(gh api repos/$repo/releases/tags/$tag --jq ".assets[] | select(.name == \"$t\") | .id" 2>/dev/null) && | |
| 287 | - [ -n "$id" ] && | |
| 288 | - gh api -H 'Accept: application/octet-stream' repos/$repo/releases/assets/$id >$d/$t 2>/dev/null || | |
| 289 | - { rm -f $d/$t; echo "boot: can't fetch $t; put it in $d" >&2; exit 1; } | |
| 290 | - fi | |
| 291 | -fi | |
| 292 | -if ! echo "$sum $d/$t" | sha256sum -c --quiet - >/dev/null 2>&1; then | |
| 293 | - echo "boot: $d/$t isn't $tag's tarball: its SHA-256 isn't BOOT's" >&2 | |
| 294 | - exit 1 | |
| 295 | -fi | |
| 296 | -rm -rf $d/raz-$v-linux-x86_64 | |
| 297 | -tar -xzf $d/$t -C $d | |
| 298 | -cp $d/raz-$v-linux-x86_64/raz $d/raz | |
| 299 | -ln -sfn ../../lib $d/lib | |
| 300 | -``` | |
| 89 | +1. Once v0.20.0 is released and its sum checked: `BOOT` names v0.20.0 | |
| 90 | + (a commit of its own). Then `src/` and the library it imports may | |
| 91 | + use `PTR`: `Sys`'s private `bytes` (both `Sys` files), which turns a | |
| 92 | + slice into a pointer or `nil`, gives way to `PTR`. `write`, `read` | |
| 93 | + and `send` keep their test for an empty slice, which is behaviour | |
| 94 | + (no call is made), not a guard. | |
| 95 | +2. `PROPOSALS.md` holds what waits for a later thaw. |
| @@ -15,10 +15,12 @@ | ||
| 15 | 15 | mkdir -p build/src |
| 16 | 16 | printf 'module Version;\nconst Text* = "%s";\nend Version.\n' "$$(tr -d "'" < build/version.inc)" >$@ |
| 17 | 17 | |
| 18 | -# The version is git's name for the commit; the file changes only when | |
| 19 | -# that does, so raz isn't rebuilt for nothing. | |
| 18 | +# The version is git's name for the commit, or VERSION where it is given | |
| 19 | +# (make dist REV=... VERSION=0.20.0 packs a release before its tag is | |
| 20 | +# pushed, as the tag will); the file changes only when that does, so | |
| 21 | +# raz isn't rebuilt for nothing. | |
| 20 | 22 | build/version.inc: FORCE | build |
| 21 | - @v=$$(git describe --tags --dirty 2>/dev/null || echo unknown); \ | |
| 23 | + @v=$(if $(VERSION),$(VERSION),$$(git describe --tags --dirty 2>/dev/null || echo unknown)); \ | |
| 22 | 24 | v="'$${v#v}'"; echo "$$v" | cmp -s - $@ || echo "$$v" >$@ |
| 23 | 25 | |
| 24 | 26 | FORCE: |
| @@ -138,7 +140,9 @@ | ||
| 138 | 140 | # it reads beside itself, the tools a program's make may build (the |
| 139 | 141 | # formatter, Doc and the Scan they share) and the manual pages, V being what raz |
| 140 | 142 | # --version says. It is made of the commit REV, HEAD unless given: CI |
| 141 | -# packs the tag it checked out, and site/build.py each tag it lacks. | |
| 143 | +# packs the tag it checked out, and site/build.py each tag it lacks. A | |
| 144 | +# release whose tag isn't pushed yet is made with VERSION, its version | |
| 145 | +# without the v: the same tarball as the tag's, once the tag is at REV. | |
| 142 | 146 | # |
| 143 | 147 | # The tarball is the same, byte for byte, wherever it is made, so that |
| 144 | 148 | # its SHA-256 can be checked against GitHub's or the website's. raz is |
| @@ -168,8 +172,9 @@ | ||
| 168 | 172 | # The website, plain files in site/public/: its home page, the tour |
| 169 | 173 | # "Raz, Set, Go" (whose programs are run here, so the output shown is |
| 170 | 174 | # real), the report and the latest release's tarball. site/build.py |
| 171 | -# says how; it needs ./raz and pandoc. | |
| 175 | +# says how; it needs ./raz and pandoc. RELEASES, "vX.Y.Z=COMMIT ...", | |
| 176 | +# names releases whose tags aren't pushed yet. | |
| 172 | 177 | site: raz pdf |
| 173 | - python3 site/build.py | |
| 178 | + python3 site/build.py $(RELEASES) | |
| 174 | 179 | |
| 175 | 180 | .PHONY: prev-bench fixpoint check gdb bench kernels stress alpine fmt loc man pdf dist site clean install uninstall |
| @@ -431,11 +431,11 @@ | ||
| 431 | 431 | rpg and rsqlite, each when it moves its pin. The mending is mechanical, |
| 432 | 432 | and the compiler names it at each place. |
| 433 | 433 | |
| 434 | -**The seed first.** The seed, frozen, can't read a marked call, and it | |
| 435 | -builds `src/` and reads `Sys` and `CAbi`. So this thaw needs the new | |
| 436 | -seed a release makes (CLAUDE.md, "The compiler and the seed") before | |
| 437 | -`src/` and that part of the library can be marked: the owner's call, | |
| 438 | -and the first step. | |
| 434 | +**BOOT first.** The release `BOOT` names can't read a marked call, and | |
| 435 | +it builds `src/` and reads `Sys` and `CAbi`. So this thaw needs a | |
| 436 | +release that reads the marks, named by `BOOT` (CLAUDE.md, "The compiler | |
| 437 | +and BOOT"), before `src/` and that part of the library can be marked: | |
| 438 | +the owner's call, and the first step. | |
| 439 | 439 | |
| 440 | 440 | Then, one commit each: |
| 441 | 441 | |
| @@ -461,10 +461,10 @@ | ||
| 461 | 461 | and `Opt`, but mostly noise in `src/Parse.raz`, where `var x` stands |
| 462 | 462 | on nearly every call. Left open, by the owner's word: |
| 463 | 463 | |
| 464 | -1. **The seed.** A release of today's compiler can't read the marks | |
| 465 | - either, so "the seed first" can't work as written: it takes two | |
| 464 | +1. **BOOT.** A release of today's compiler can't read the marks | |
| 465 | + either, so "BOOT first" can't work as written: it takes two | |
| 466 | 466 | releases, one that accepts every new form without requiring it, |
| 467 | - made the seed, then one that marks `src/` and requires the marks. | |
| 467 | + named by `BOOT`, then one that marks `src/` and requires the marks. | |
| 468 | 468 | 2. **An error here.** Part 3's `Names.put(var table, keep buf[0..n], 1)` |
| 469 | 469 | lacks `keep 1`. (The others the review found were in parts 2, 4 |
| 470 | 470 | and 5, mended when they went into the report.) |
| @@ -932,9 +932,9 @@ | ||
| 932 | 932 | say it: rmacs, ravite, the tools and ten of `src/`'s modules (by |
| 933 | 933 | `ADR`), each mended by one line, which |
| 934 | 934 | the compiler's message names. The compiler's cost is a flag on the |
| 935 | -module, checked at each of those places. Since the seed doesn't know | |
| 936 | -`unsafe;`, `src/` can't say it until a release makes a new seed: for | |
| 937 | -one release a missing `unsafe;` is a warning, then an error. | |
| 935 | +module, checked at each of those places. Since BOOT's release doesn't | |
| 936 | +know `unsafe;`, `src/` can't say it until `BOOT` names one that does: | |
| 937 | +for one release a missing `unsafe;` is a warning, then an error. | |
| 938 | 938 | |
| 939 | 939 | Pieces 1 and 2 are small and change no program; 3 is a mend; 4 needs |
| 940 | 940 | a thaw. |
| @@ -951,68 +951,6 @@ | ||
| 951 | 951 | volume 2. Volume 1 needs at most a sentence, that `link static;` |
| 952 | 952 | means no C library where there are no system calls to make. The |
| 953 | 953 | compiler needs a PE writer and Microsoft's calling convention. |
| 954 | - | |
| 955 | -## A slice's pointer | |
| 956 | - | |
| 957 | -A slice is two words: the address its elements start at, and how many | |
| 958 | -there are (5.3). `LEN(s)` gives the second; nothing gives the first. | |
| 959 | -A program that needs it writes `ADR(s[0])`, the address of the first | |
| 960 | -element. That works only when there is a first element: when `s` is | |
| 961 | -empty, `s[0]` is an index out of range, and the program stops. | |
| 962 | - | |
| 963 | -Where it bites is a program that keeps bytes as a pointer and a | |
| 964 | -length, as an interpreter keeps a string value: | |
| 965 | - | |
| 966 | -``` | |
| 967 | -type Value = record kind: Kind; n: INT; p: ^U8; end; | |
| 968 | - | |
| 969 | -proc strVal(s: []U8): Value; | |
| 970 | -begin | |
| 971 | - return {kind: kStr, n: LEN(s), p: ADR(s[0])}; (* stops when s is "" *) | |
| 972 | -end; | |
| 973 | -``` | |
| 974 | - | |
| 975 | -It compiles, and passes every test that has no empty string in it; | |
| 976 | -the first `""` stops the program. So every place that turns a slice | |
| 977 | -into a pointer must test first: | |
| 978 | - | |
| 979 | -``` | |
| 980 | -proc strVal(s: []U8): Value; | |
| 981 | -begin | |
| 982 | - if LEN(s) = 0 then return {kind: kStr}; end; (* n is 0, p nil *) | |
| 983 | - return {kind: kStr, n: LEN(s), p: ADR(s[0])}; | |
| 984 | -end; | |
| 985 | -``` | |
| 986 | - | |
| 987 | -The library does the same before each call to C: `Sys.write` over C | |
| 988 | -returns 0 for an empty `s` before it writes `C.write(fd, ADR(s[0]), | |
| 989 | -LEN(s))`. The test is easy to forget and says nothing about what the | |
| 990 | -program means. | |
| 991 | - | |
| 992 | -The proposal: a built-in `PTR(s)`, the address the slice or array `s` | |
| 993 | -starts at, a `^T` for a `[]T` or `[n]T`, with no check. For a slice | |
| 994 | -that isn't empty it is `ADR(s[0])`. For an empty one it is what the | |
| 995 | -slice holds: `nil` for a slice variable as it starts (section 4), and | |
| 996 | -for one cut empty from another, `t[3..3]`, an address that mustn't be | |
| 997 | -read through, as the end of an array mustn't. With it: | |
| 998 | - | |
| 999 | -``` | |
| 1000 | -proc strVal(s: []U8): Value; | |
| 1001 | -begin | |
| 1002 | - return {kind: kStr, n: LEN(s), p: PTR(s)}; | |
| 1003 | -end; | |
| 1004 | -``` | |
| 1005 | - | |
| 1006 | -The way back is there already: `v.p[0..v.n]` is the slice again | |
| 1007 | -(6.4), empty when `v.n` is 0, whatever `v.p` is. Reading through the | |
| 1008 | -pointer is as unchecked as through any pointer; `PTR` only stops the | |
| 1009 | -program from failing where nothing is read. | |
| 1010 | - | |
| 1011 | -It costs a row in the table of 6.8. A predeclared name can be hidden | |
| 1012 | -(section 3), so it breaks no program. | |
| 1013 | - | |
| 1014 | -Met in concha's `Ccore`, in `bufVal` and `listVal`, and in `Sys` over | |
| 1015 | -C, before each call that takes a buffer. | |
| 1016 | 954 | |
| 1017 | 955 | ## An enumeration's name read against the type it is given to |
| 1018 | 956 |
| @@ -24,7 +24,7 @@ | ||
| 24 | 24 | $ examples/Hello |
| 25 | 25 | hello, world |
| 26 | 26 | |
| 27 | -The compiler is about 11,400 lines of raz, written in itself: one pass, no | |
| 27 | +The compiler is about 11,500 lines of raz, written in itself: one pass, no | |
| 28 | 28 | intermediate form, no optimizer. It writes x86-64 machine code and the |
| 29 | 29 | ELF executable itself, with no assembler or linker, and compiles about |
| 30 | 30 | 500,000 lines a second. |
| @@ -37,7 +37,7 @@ | ||
| 37 | 37 | | `doc/compiler.md` | A guide to reading the compiler, file by file | |
| 38 | 38 | | `doc/raz.1`, `doc/raz.7`, `doc/raz-tutorial.7` | The manual pages: the command, the language at a glance, a tour; `make man` makes the library's, raz-lib(3), from `lib/` | |
| 39 | 39 | | `src/` | The compiler, in raz | |
| 40 | -| `seed/` | The first compiler, in Free Pascal: frozen, kept only to build `src/` the first time | | |
| 40 | +| `BOOT` | The release that builds `src/`, by its tag and its tarball's SHA-256 | | |
| 41 | 41 | | `lib/` | The library, in raz; the compiler finds it beside itself | |
| 42 | 42 | | `examples/` | Small programs, each with the output it should give | |
| 43 | 43 | | `tools/Doc.raz` | Prints what a module exports, with its comments | |
| @@ -51,12 +51,17 @@ | ||
| 51 | 51 | |
| 52 | 52 | ## Building |
| 53 | 53 | |
| 54 | -The compiler is written in raz, so building it takes a raz. The first | |
| 55 | -time there is none, and Free Pascal 3.2.2 (`apt-get install fp-compiler`) | |
| 56 | -builds the seed, the Pascal compiler in `seed/`, which builds the | |
| 57 | -compiler, `src/`, in the repository's root. Free Pascal is needed for | |
| 58 | -nothing else, and `make fixpoint` has the compiler build itself and | |
| 59 | -checks that the result is the same file. | |
| 54 | +The compiler is written in raz, so building it takes a raz: the | |
| 55 | +release `BOOT` names. `make` fetches that release's tarball into | |
| 56 | +`build/boot/` (by curl, or by `gh` where the repository is private), | |
| 57 | +checks its SHA-256 against `BOOT`'s, and has its `raz` build the | |
| 58 | +compiler, `src/`, in the repository's root, against this `lib/`. On a | |
| 59 | +machine with no network, put the tarball in `build/boot/` by hand. | |
| 60 | +Each release is built by the one before it, back to v0.19.0, which the | |
| 61 | +first compiler, in Free Pascal, built; git has that compiler, in | |
| 62 | +`seed/` at v0.19.0, so raz can be built again from source alone. `make | |
| 63 | +fixpoint` has the compiler build itself and checks that the result is | |
| 64 | +the same file. | |
| 60 | 65 | |
| 61 | 66 | make # ./raz |
| 62 | 67 | make install # ~/.local/bin/raz, its library and tools in |
| @@ -72,11 +77,12 @@ | ||
| 72 | 77 | |
| 73 | 78 | make check # every example and test, against what it should give |
| 74 | 79 | make bench # the compiler's speed on a program of 350,000 lines |
| 80 | + make prev-bench # the same against BOOT's: more than a tenth slower fails | |
| 81 | + make kernels # the code's speed against FPC -O2's (apt-get install fp-compiler) | |
| 75 | 82 | make stress # 40,000 threads, started and joined |
| 76 | 83 | make gdb # gdb stops at a line of raz and names it |
| 77 | 84 | make fmt # the library, examples and tools are formatted |
| 78 | 85 | make loc # the compiler's lines |
| 79 | - make tests # tests of the scanner, encoder and linker on their own | |
| 80 | 86 | make pdf # build/raz.pdf and build/raz-lib.pdf, the two volumes, by pandoc and Chromium |
| 81 | 87 | make dist # build/raz-V-linux-x86_64.tar.gz, the release's tarball |
| 82 | 88 | make site # site/public/, the website, by pandoc and python3 |
| @@ -145,7 +151,9 @@ | ||
| 145 | 151 | `F32`, `F64`. No conversion happens unless it is written. |
| 146 | 152 | - Arrays, slices (`[]T`, checked), pointers (unchecked), records laid |
| 147 | 153 | out as C lays them out, packed records, variants with `match`, |
| 148 | - enumerations and sets, procedure types. | |
| 154 | + enumerations and sets, procedure types. `LEN(s)` and `PTR(s)` take a | |
| 155 | + slice apart into a length and a pointer, for a record or for C, an | |
| 156 | + empty one too. | |
| 149 | 157 | - `^VOLATILE T`: every access through it is one instruction of its |
| 150 | 158 | size, in the order written. `CAS`, `XCHG`, `XADD`, `FENCE`. |
| 151 | 159 | - `and`, `or` and `not` for `BOOL`s; `&`, `|`, `xor` and `~` for bits; |
| @@ -201,16 +209,16 @@ | ||
| 201 | 209 | The compiler says its own version and that of the report it follows: |
| 202 | 210 | |
| 203 | 211 | $ ./raz --version |
| 204 | - raz 0.18.1, report 2026-10.32 | |
| 212 | + raz 0.20.0, report 2026-10.34 | |
| 205 | 213 | |
| 206 | 214 | The compiler's version is git's name for the commit it was built from: |
| 207 | -`0.18.1` at the tag `v0.18.1`, `0.18.1-5-g38d29a8` five commits past it. | |
| 215 | +`0.20.0` at the tag `v0.20.0`, `0.20.0-5-g38d29a8` five commits past it. | |
| 208 | 216 | To release, check `main` and tag it; the tag's message is what |
| 209 | 217 | `raz --version` will print: |
| 210 | 218 | |
| 211 | 219 | $ make check |
| 212 | - $ git tag -a v0.18.1 -m 'raz 0.18.1, report 2026-10.32' | |
| 213 | - $ git push origin v0.18.1 | |
| 220 | + $ git tag -a v0.20.0 -m 'raz 0.20.0, report 2026-10.34' | |
| 221 | + $ git push origin v0.20.0 | |
| 214 | 222 | |
| 215 | 223 | GitHub then builds and checks the tag, and makes a release of it with |
| 216 | 224 | a tarball of `raz`, its `lib/` and its manual pages, made by `make |
| @@ -218,10 +226,14 @@ | ||
| 218 | 226 | Actions tab: run "ci" with its name. Then `make site` adds the new |
| 219 | 227 | tag's tarball to the website's `download/` (it builds it from the tag, |
| 220 | 228 | apart from the tree at hand); commit `site/public/` and push to publish |
| 221 | -it. Every release since 0.7.1 stays there, at its own name, and is | |
| 229 | +it. A release whose tag isn't pushed yet goes there too, by `make site | |
| 230 | +RELEASES="v0.20.0=COMMIT"`: `make dist REV=COMMIT VERSION=0.20.0` makes | |
| 231 | +the tarball the tag will, byte for byte. Every release since 0.7.1 stays there, at its own name, and is | |
| 222 | 232 | never made again, so that its SHA-256 holds: programs pin raz by it. |
| 223 | 233 | From 0.15.0 on, `make dist` makes the same tarball, byte for byte, |
| 224 | -wherever it runs, so GitHub's and the website's agree. | |
| 234 | +wherever it runs, so GitHub's and the website's agree. Once a release | |
| 235 | +is out, `BOOT` may name it, and the next one is built by it: then | |
| 236 | +`src/` may use what it brought. | |
| 225 | 237 | |
| 226 | 238 | A version of the report is named by its month and a count; the report's |
| 227 | 239 | last section says what each version changed. |
| @@ -1,10 +1,13 @@ | ||
| 1 | 1 | # Reading the raz compiler |
| 2 | 2 | |
| 3 | -The compiler is eleven files of raz, about 11,400 lines of code (the | |
| 4 | -budget is 14,000). It is its own compiler: the | |
| 5 | -frozen Pascal compiler in `seed/` builds `src/` the first time, and | |
| 6 | -after that a raz builds `src/` (`make fixpoint` checks that it makes | |
| 7 | -itself again, byte for byte). This guide walks through the files in the order they are best read: from the | |
| 3 | +The compiler is eleven files of raz, about 11,500 lines of code (the | |
| 4 | +budget is 14,000). It is its own compiler: a release of it, the one | |
| 5 | +`BOOT` names, builds `src/`, and `make fixpoint` checks that what it | |
| 6 | +makes makes itself again, byte for byte. Each release was built by the | |
| 7 | +one before it, back to v0.19.0, which the Pascal compiler it was ported | |
| 8 | +from built; that compiler, the seed, is in git at v0.19.0 (`seed/`), | |
| 9 | +and a comment that names "the seed" means it. This guide walks through | |
| 10 | +the files in the order they are best read: from the | |
| 8 | 11 | characters of a source file to the bytes of an executable. It assumes |
| 9 | 12 | you know the language from `doc/raz.md`, and enough x86-64 to read a |
| 10 | 13 | disassembly. The manual pages say the rest: `raz(1)` the command, |
| @@ -15,12 +18,12 @@ | ||
| 15 | 18 | |---|---|---|---| |
| 16 | 19 | | `src/Diag.raz` | 410 | 315 | Messages: positions, source excerpts, colour, counts | |
| 17 | 20 | | `src/Scan.raz` | 1,148 | 949 | Symbols, literals, comments, positions | |
| 18 | -| `src/Sym.raz` | 712 | 570 | Types, objects, scopes, layout | | |
| 21 | +| `src/Sym.raz` | 713 | 571 | Types, objects, scopes, layout | | |
| 19 | 22 | | `src/Chunk.raz` | 363 | 279 | The compiled program: chunks, fixups, line notes | |
| 20 | 23 | | `src/X64.raz` | 1,517 | 1,253 | The instruction encoder, jumps within a procedure, the assembler | |
| 21 | 24 | | `src/Gen.raz` | 2,552 | 1,821 | The stack machine, for x86-64: values, operations, checks, calls, frames | |
| 22 | -| `src/Item.raz` | 2,115 | 1,701 | Items: types, constants, variables, operators, conversions, calls | | |
| 23 | -| `src/Parse.raz` | 4,218 | 3,648 | Declarations, statements, expressions, built-ins, recovery, warnings | | |
| 25 | +| `src/Item.raz` | 2,175 | 1,747 | Items: types, constants, variables, operators, conversions, calls | | |
| 26 | +| `src/Parse.raz` | 4,251 | 3,676 | Declarations, statements, expressions, built-ins, recovery, warnings | | |
| 24 | 27 | | `src/Link.raz` | 381 | 298 | Tree shaking, layout, patching, the places | |
| 25 | 28 | | `src/Elf.raz` | 449 | 355 | Static and dynamic ELF, symbol table, line numbers | |
| 26 | 29 | | `src/Raz.raz` | 326 | 253 | The command line | |
| @@ -1026,7 +1029,9 @@ | ||
| 1026 | 1029 | operand (`Mem`) or two registers. Everything else (`movRR`, `load`, |
| 1027 | 1030 | `store`, `alu`, `sse`, ...) is a line or two that calls them with the |
| 1028 | 1031 | right opcode. Only the instructions the code generator uses are here. |
| 1029 | -`test/enctest.pas` emits one of each, with the seed's encoder, for `objdump` to check. `here` is | |
| 1032 | +Each was checked against `objdump` when it was written (`raz -S` | |
| 1033 | +lists what the compiler made, and `objdump -d` reads the executable), | |
| 1034 | +and every program `make check` runs uses them. `here` is | |
| 1030 | 1035 | the address of the code being written, as an operand. |
| 1031 | 1036 | |
| 1032 | 1037 | The assembler, `assemble`, reads a code procedure's instructions with |
| @@ -1848,8 +1853,8 @@ | ||
| 1848 | 1853 | a case in `builtin` in `Parse.raz`, and the code, in `Gen.raz` if it is an |
| 1849 | 1854 | instruction, or of calls to gen right there. |
| 1850 | 1855 | - **An instruction:** a routine in `X64.raz` built on `opM` or `opR`, |
| 1851 | - and a line in `test/enctest.pas` to check its encoding (the seed's | |
| 1852 | - test), and a program in `conform/` or `test/` that uses it. | |
| 1856 | + its encoding checked against `objdump -d` once, and a program in | |
| 1857 | + `conform/` or `test/` that uses it. | |
| 1853 | 1858 | - **A machine:** a new `Gen.raz`, answering the same calls, and an |
| 1854 | 1859 | encoder and assembler for it in place of `X64.raz`. |
| 1855 | 1860 | - **A statement:** a reserved word in `Scan.raz` (in `Sym` and `words`, |
| @@ -1858,12 +1863,17 @@ | ||
| 1858 | 1863 | - **A check that fails:** `check` in `Gen.raz`, and the message in |
| 1859 | 1864 | `lib/Rt.raz`'s `fail`; a reason a signal gives, `onSignal` there. |
| 1860 | 1865 | |
| 1861 | -The compiler is in raz. `make raz` builds it with the seed, the frozen | |
| 1862 | -Pascal compiler in `seed/` (which needs Free Pascal, and is never edited | |
| 1863 | -to suit `src/`); a raz that already exists could do it as well. | |
| 1864 | -`make fixpoint` has the seed's build compile `src/`, that compile it | |
| 1865 | -again, and that again, and checks that the last two are the same file. | |
| 1866 | -`make seed-bench` compares the speed of the two. Each unit of `src/` | |
| 1867 | -was once tested against the seed's, while it was ported; that test was | |
| 1868 | -dropped after v0.17.0, as the two had grown apart. After any change: `make check`, `make bench`, | |
| 1869 | -`make loc`. | |
| 1866 | +The compiler is in raz. `make raz` builds it with the release `BOOT` | |
| 1867 | +names, by its tag and its tarball's SHA-256: `src/boot.sh` fetches the | |
| 1868 | +tarball into `build/boot/`, checks the sum, and puts its `raz` there | |
| 1869 | +with this `lib/` beside it, so that `src/` is built against today's | |
| 1870 | +library. So `src/`, and the modules of `lib/` it imports, use only what | |
| 1871 | +that release knows: v0.19.0 has `const` parameters, views and the | |
| 1872 | +widening, but not `PTR`. `make fixpoint` has BOOT's compiler build | |
| 1873 | +`src/`, that build it again, and that again, and checks that the last | |
| 1874 | +two are the same file. `make prev-bench` compares this compiler's speed | |
| 1875 | +with BOOT's on the same program, and fails if it is more than a tenth | |
| 1876 | +slower. Each unit of `src/` was once tested against the seed's, while it | |
| 1877 | +was ported; that test was dropped after v0.17.0, as the two had grown | |
| 1878 | +apart, and the seed itself after v0.19.0. After any change: `make | |
| 1879 | +check`, `make bench`, `make loc`. |
| @@ -531,6 +531,69 @@ | ||
| 531 | 531 | .Cm b^.lo , |
| 532 | 532 | never |
| 533 | 533 | .Cm b.lo . |
| 534 | +.Pp | |
| 535 | +A slice is a pointer and a length, and a record can keep the two | |
| 536 | +apart, as an interpreter keeps a string, or as C wants them: | |
| 537 | +.Bd -literal -offset indent | |
| 538 | +module Spans; | |
| 539 | +import Out; | |
| 540 | + | |
| 541 | +type Span = record p: ^U8; n: INT; end; | |
| 542 | + | |
| 543 | +proc spanOf(s: []U8): Span; | |
| 544 | +begin | |
| 545 | + return {p: PTR(s), n: LEN(s)}; | |
| 546 | +end; | |
| 547 | + | |
| 548 | +proc text(sp: Span): []U8; | |
| 549 | +begin | |
| 550 | + return sp.p[0..sp.n]; | |
| 551 | +end; | |
| 552 | + | |
| 553 | +proc main*; | |
| 554 | +var words: [3]Span; i: INT; | |
| 555 | +begin | |
| 556 | + words := [spanOf("one"), spanOf(""), spanOf("three")]; | |
| 557 | + for i := 0 to 2 do | |
| 558 | + Out.int(words[i].n); Out.char(' '); | |
| 559 | + Out.str(text(words[i])); Out.ln; | |
| 560 | + end; | |
| 561 | +end; | |
| 562 | + | |
| 563 | +end Spans. | |
| 564 | +.Ed | |
| 565 | +.Bd -literal -offset indent | |
| 566 | +3 one | |
| 567 | +0 | |
| 568 | +5 three | |
| 569 | +.Ed | |
| 570 | +.Pp | |
| 571 | +.Cm LEN(s) | |
| 572 | +is the length, and | |
| 573 | +.Cm PTR(s) | |
| 574 | +the pointer, a | |
| 575 | +.Cm ^U8 | |
| 576 | +for a | |
| 577 | +.Cm []U8 , | |
| 578 | +with no check. | |
| 579 | +.Cm ADR(s[0]) | |
| 580 | +looks the same, and passes every test but the one with an empty | |
| 581 | +string: there | |
| 582 | +.Cm s[0] | |
| 583 | +is out of range, and the program stops. | |
| 584 | +.Cm PTR | |
| 585 | +of an empty slice is what the slice holds, which is | |
| 586 | +.Cm nil | |
| 587 | +for one never set, so nothing needs testing first. | |
| 588 | +.Cm sp.p[0..sp.n] | |
| 589 | +is the slice again, empty when | |
| 590 | +.Cm sp.n | |
| 591 | +is 0, whatever | |
| 592 | +.Cm sp.p | |
| 593 | +is. | |
| 594 | +Of an array, | |
| 595 | +.Cm PTR(a) | |
| 596 | +is the address of its first element. | |
| 534 | 597 | .Sh 7. BYTES AND VIEWS |
| 535 | 598 | A file, a network packet or a device hands a program bytes, and the |
| 536 | 599 | program wants numbers and records out of them. |
| @@ -1216,6 +1279,11 @@ | ||
| 1216 | 1279 | .Cm a |
| 1217 | 1280 | as a pointer to an |
| 1218 | 1281 | .Cm INT . |
| 1282 | +A slice goes to C as two arguments, | |
| 1283 | +.Cm PTR(s) | |
| 1284 | +and | |
| 1285 | +.Cm LEN(s) , | |
| 1286 | +which an empty slice gives too (section 6). | |
| 1219 | 1287 | .Pp |
| 1220 | 1288 | A program that uses C is linked against it dynamically, and starts |
| 1221 | 1289 | through it; one that doesn't is a static executable with nothing in it |
| @@ -1,8 +1,12 @@ | ||
| 1 | 1 | #!/usr/bin/env python3 |
| 2 | 2 | """Builds the website into site/public/ from site/content/ and the repository. |
| 3 | 3 | |
| 4 | - python3 site/build.py | |
| 4 | + python3 site/build.py [vX.Y.Z=COMMIT ...] | |
| 5 | 5 | |
| 6 | +Each vX.Y.Z=COMMIT is a release whose tag isn't pushed yet: it is | |
| 7 | +offered as if the tag were at COMMIT, its tarball made by make dist | |
| 8 | +with VERSION, the same tarball the tag will give. | |
| 9 | + | |
| 6 | 10 | The site is plain files: open public/index.html, or put the folder on |
| 7 | 11 | any web server. Nothing runs in the reader's browser; the code on the |
| 8 | 12 | tour's pages is run here, by ./raz, and the output shown is what it |
| @@ -335,7 +339,7 @@ | ||
| 335 | 339 | # manual, which make dist packs |
| 336 | 340 | FIRST_RELEASE = "v0.7.1" |
| 337 | 341 | |
| 338 | -def build_download(): | |
| 342 | +def build_download(untagged): | |
| 339 | 343 | """Every release's tarball from FIRST_RELEASE on, in public/download/ |
| 340 | 344 | with its SHA-256, and /download/latest leading to the newest; a list |
| 341 | 345 | of (version, file name, SHA-256), oldest first. A program's CI can |
| @@ -348,11 +352,14 @@ | ||
| 348 | 352 | git = lambda *a: subprocess.run(("git", "-C", ROOT) + a, capture_output=True, |
| 349 | 353 | text=True, check=True).stdout.strip() |
| 350 | 354 | releases = [] |
| 351 | - for tag in git("tag", "-l", "v*", "--sort=v:refname", "--contains", FIRST_RELEASE).split(): | |
| 355 | + tags = git("tag", "-l", "v*", "--sort=v:refname", "--contains", FIRST_RELEASE).split() | |
| 356 | + revs = [(tag, tag, []) for tag in tags] | |
| 357 | + revs += [(tag, rev, ["VERSION=" + tag[1:]]) for tag, rev in untagged if tag not in tags] | |
| 358 | + for tag, rev, version in revs: | |
| 352 | 359 | name = "raz-%s-linux-x86_64.tar.gz" % tag[1:] |
| 353 | 360 | made = os.path.join(OUT, "download", name) |
| 354 | 361 | if not os.path.exists(made): |
| 355 | - subprocess.run(["make", "-s", "-C", ROOT, "dist", "REV=" + tag], | |
| 362 | + subprocess.run(["make", "-s", "-C", ROOT, "dist", "REV=" + rev] + version, | |
| 356 | 363 | stdout=subprocess.DEVNULL, check=True) |
| 357 | 364 | shutil.copy(os.path.join(ROOT, "build", name), made) |
| 358 | 365 | digest = hashlib.sha256(open(made, "rb").read()).hexdigest() |
| @@ -420,7 +427,10 @@ | ||
| 420 | 427 | build_spec() |
| 421 | 428 | for pdf in ("raz.pdf", "raz-lib.pdf"): # made by make pdf |
| 422 | 429 | shutil.copy(os.path.join(ROOT, "build", pdf), OUT) |
| 423 | - build_home(build_download()) | |
| 430 | + untagged = [a.split("=", 1) for a in sys.argv[1:]] | |
| 431 | + if not all(len(u) == 2 and re.match(r"v\d+\.\d+\.\d+$", u[0]) for u in untagged): | |
| 432 | + sys.exit("usage: build.py [vX.Y.Z=COMMIT ...]") | |
| 433 | + build_home(build_download(untagged)) | |
| 424 | 434 | print("site/public: %s lessons" % " + ".join(map(str, counts))) |
| 425 | 435 | |
| 426 | 436 | main() |
| @@ -230,3 +230,37 @@ | ||
| 230 | 230 | |
| 231 | 231 | end Chain. |
| 232 | 232 | ``` |
| 233 | + | |
| 234 | +## A slice's pointer | |
| 235 | + | |
| 236 | +A slice is a pointer and a length, and a record can keep the two apart: an interpreter keeps a string so, and C takes one so. `LEN(s)` is the length. The pointer looks like `ADR(s[0])`, the address of the first element, and that works until the slice is empty: then there is no first element, `s[0]` is out of range, and the program stops. | |
| 237 | + | |
| 238 | +```raz Empty fail | |
| 239 | +module Empty; | |
| 240 | +import Out; | |
| 241 | + | |
| 242 | +type Span = record p: ^U8; n: INT; end; | |
| 243 | + | |
| 244 | +proc spanOf(s: []U8): Span; | |
| 245 | +begin | |
| 246 | + return {p: ADR(s[0]), n: LEN(s)}; | |
| 247 | +end; | |
| 248 | + | |
| 249 | +proc main*; | |
| 250 | +var a, b: Span; | |
| 251 | +begin | |
| 252 | + a := spanOf("one"); | |
| 253 | + Out.int(a.n); Out.ln; | |
| 254 | + b := spanOf(""); | |
| 255 | + Out.int(b.n); Out.ln; | |
| 256 | +end; | |
| 257 | + | |
| 258 | +end Empty. | |
| 259 | +``` | |
| 260 | + | |
| 261 | +`PTR(s)` is the pointer itself, a `^U8` for a `[]U8`, with no check. For a slice that isn't empty it is `ADR(s[0])`; for an empty one it is what the slice holds, `nil` for one never set. So nothing needs testing first, and `sp.p[0..sp.n]` makes the slice again, empty when `sp.n` is 0, whatever `sp.p` is: | |
| 262 | + | |
| 263 | +```raz Spans run | |
| 264 | +``` | |
| 265 | + | |
| 266 | +Of an array, `PTR(a)` is the address of its first element, a `^T` where `ADR(a)` is a `^[n]T`. Reading through the pointer is as unchecked as through any pointer: the length is yours to keep with it. The compiler says so when the two are mixed up: a slice given where a pointer is wanted is an error whose help says to write `PTR(s)` and `LEN(s)`, and a pointer given where a slice is, `p[0..n]`. |
| @@ -1,13 +1,17 @@ | ||
| 1 | 1 | # src: the compiler in raz |
| 2 | 2 | |
| 3 | -The port of the Pascal compiler, the **seed** in `../seed/`, to raz. | |
| 3 | +The port of the Pascal compiler, the **seed**, to raz. The seed built | |
| 4 | +`src/` from the port to v0.19.0, and went in v0.20.0; git has it, in | |
| 5 | +`seed/` at the tag v0.19.0. Since then the release `../BOOT` names | |
| 6 | +builds `src/` (`boot.sh` fetches it), and a comment here that names | |
| 7 | +the seed means the Pascal compiler. | |
| 4 | 8 | |
| 5 | 9 | One module to a seed unit, with the seed's name, written to the same |
| 6 | 10 | rules: plain code, each module opening with what it is, what it |
| 7 | -depends on and what it leaves out. The seed is never edited from here. | |
| 11 | +depends on and what it leaves out. | |
| 8 | 12 | |
| 9 | - make seed-bench # the scanner's and the compiler's speed against the seed's | |
| 10 | - make fixpoint # the seed builds src, that builds src, that builds it again | |
| 13 | + make prev-bench # the compiler's speed against BOOT's: a tenth slower fails | |
| 14 | + make fixpoint # BOOT's builds src, that builds src, that builds it again | |
| 11 | 15 | |
| 12 | 16 | While it was ported, each unit was tested against the seed's: a pair |
| 13 | 17 | of dumpers, one over each side's units, read the same files or ran the |
| @@ -20,17 +24,17 @@ | ||
| 20 | 24 | `test/Recover.raz`, the pattern of going on after an error, is run by |
| 21 | 25 | `make check`. |
| 22 | 26 | |
| 23 | -`make fixpoint` (`fixpoint.sh`) is the proof that the port is whole: | |
| 24 | -the seed builds `Raz.raz` (stage 1), stage 1 builds it (stage 2), and | |
| 25 | -stage 2 builds it again (stage 3). Stages 2 and 3 must be the same | |
| 26 | -file; they are (stage 1 is not, since v0.10.1: the port makes better code | |
| 27 | -than the seed's). Stage 3 then stands in for `./raz`, and `make check` and | |
| 27 | +`make fixpoint` (`fixpoint.sh`) is the proof that the compiler is | |
| 28 | +whole: BOOT's release builds `Raz.raz` (stage 1), stage 1 builds it | |
| 29 | +(stage 2), and stage 2 builds it again (stage 3). Stages 2 and 3 must | |
| 30 | +be the same file; they are (stage 1 is not, when BOOT's compiler makes | |
| 31 | +other code than this one; until v0.19.0 the seed was stage 0). Stage 3 then stands in for `./raz`, and `make check` and | |
| 28 | 32 | `make bench` run on it. Each stage is built by the same command in the |
| 29 | 33 | same place, since a program holds the paths it was made from. |
| 30 | 34 | |
| 31 | 35 | ## What the port found |
| 32 | 36 | |
| 33 | -Not the seed's to mend; for the owner to choose. | |
| 37 | +What the port found in the seed, which the seed kept; a record now. | |
| 34 | 38 | |
| 35 | 39 | - **Names.** An exported variable is read-only outside its module, so |
| 36 | 40 | what the parser sets in the seed's `diag` and `scan` (`quiet`, |
| @@ -106,7 +110,10 @@ | ||
| 106 | 110 | same; whether the compiler built from this is slower for it is for |
| 107 | 111 | the speed test of step 4 to say. A `const` parameter (a hint that |
| 108 | 112 | the callee won't change it, so that the caller may pass its address) |
| 109 | - would be a language change: it is in `../PROPOSALS.md`. | |
| 113 | + would be a language change: it is in `../PROPOSALS.md`. (It came in | |
| 114 | + report 2026-10.33; since v0.20.0, built by v0.19.0, which has it, | |
| 115 | + the routines that every program's compile goes through take their | |
| 116 | + `Item` as `const`, measured, as `doc/compiler.md` says.) | |
| 110 | 117 | - **`Parse` and the seed's jumps.** The seed's `Guard`, `setjmp` and |
| 111 | 118 | `longjmp` are `guard`, a record of what to put back, and the `ERROR` |
| 112 | 119 | that comes up through `try` to the statement or declaration that is |
| @@ -23,8 +23,8 @@ | ||
| 23 | 23 | names one. |
| 24 | 24 | |
| 25 | 25 | Depends on: everything else, and Version, a module the build makes |
| 26 | - (build/src/Version.raz) from what git describe says, as the seed's | |
| 27 | - build/version.inc is. | |
| 26 | + (build/src/Version.raz) from build/version.inc: what git describe | |
| 27 | + says, or the make's VERSION. | |
| 28 | 28 | Leaves out: the work itself; the other units compile, link and |
| 29 | 29 | write, and this only reads the command line and runs them in order. *) |
| 30 | 30 | module Raz; |