Report 2026-10.33 is followed; the tutorial, STANDARDS.md and CLAUDE.md say so The compiler follows report 2026-10.33: the version line that let it lag goes, and raz --version says 10.33. The tutorial's section 4 shows a const parameter beside a var one, with a program make check runs; section 12 takes its shapes from a constant of variants; section 16 gives C's and Pascal's const and var their raz forms. STANDARDS.md's "library until a thaw" goes, the library having come to it. CLAUDE.md records the thaw, its readings, and the next step: v0.20.0, built by v0.19.0, drops the Pascal seed. The report grows by about one page, to 32 of 40 (counted by words; this container's pandoc can't make the PDF).
| @@ -83,7 +83,16 @@ | ||
| 83 | 83 | |
| 84 | 84 | ## Where things stand |
| 85 | 85 | |
| 86 | -v0.18.1, report 2026-10.32, is the latest release: v0.18.0's thaw (a | |
| 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`. | |
| 95 | +v0.18.1, report 2026-10.32, before it: v0.18.0's thaw (a | |
| 87 | 96 | constant typed `[]T` may be `[]`, the empty slice, as may a constant's |
| 88 | 97 | slice part), with `Vec.pop` and `Sys.Info.links`, and a constant's |
| 89 | 98 | slice part naming another module's array constant, a defect mended; |
| @@ -97,7 +106,7 @@ | ||
| 97 | 106 | compiler in raz, built by itself (Self, done); the seed in `seed/` is |
| 98 | 107 | frozen, and v0.9.1 was the last release it built. The compiler takes |
| 99 | 108 | 1.4 times the Pascal one's time; `make kernels` measures `test/bench` |
| 100 | -against FPC `-O2`. Next: what the owner chooses. What | |
| 109 | +against FPC `-O2`. What | |
| 101 | 110 | each version of the report changed is in `doc/report-history.md`, and |
| 102 | 111 | what each step did is in git; don't repeat it here. |
| 103 | 112 | |
| @@ -111,7 +120,8 @@ | ||
| 111 | 120 | for it. A wish for more, the owner's or yours, goes in |
| 112 | 121 | `PROPOSALS.md`, for a later thaw; it isn't built. Thaws happen only by the |
| 113 | 122 | owner's word (v0.6.0, reports 2026-10.13 to 10.23, 10.25 for strings, |
| 114 | -and 10.26 for `INT` and views). | |
| 123 | +10.26 for `INT` and views, and 10.33 for `const` parameters, variants | |
| 124 | +in constants and the library by `var`). | |
| 115 | 125 | |
| 116 | 126 | **The reserved words and the module names are settled.** That a word |
| 117 | 127 | is reserved, however common (`code`, `to`, `packed`, `forward`, `set`, |
| @@ -274,3 +284,20 @@ | ||
| 274 | 284 | generic module's parameters; a generic module is warned of in its |
| 275 | 285 | first instance only. Assigning a variable whole (`x :=`, `a, b :=`) |
| 276 | 286 | doesn't read it; anything else does. |
| 287 | +- A `const` parameter (report 2026-10.33) is a `var` one never changed: | |
| 288 | + passed by address always, its `Obj` `isVar` and `isConst`, an item of | |
| 289 | + it `ro`. A slice of its array may be made, to read; through it the | |
| 290 | + caller's array may be written, which the report says (8). An argument | |
| 291 | + that isn't a variable, or is a packed field, a view or volatile, goes | |
| 292 | + in a temporary of the statement. `match` on a `const` parameter or a | |
| 293 | + constant gives names that are only read. Procedure types compare | |
| 294 | + `const` as `var`. It is unused if never read, as a value parameter. | |
| 295 | +- A variant in a constant must be typed; `const D = dot;` is an error | |
| 296 | + that says to write its type. Its case is read by name (`constCase`). | |
| 297 | +- 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 | |
| 301 | + words, made a loop of `get` half again as slow as `const`. A trace | |
| 302 | + shows no `var` or `const` parameter. `Fmt`'s `format` and `put` keep | |
| 303 | + `^Buf.Buf`, since `nil` is standard output there. |
| @@ -24,7 +24,7 @@ | ||
| 24 | 24 | $ examples/Hello |
| 25 | 25 | hello, world |
| 26 | 26 | |
| 27 | -The compiler is about 10,700 lines of raz, written in itself: one pass, no | |
| 27 | +The compiler is about 11,400 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. |
| @@ -3,8 +3,8 @@ | ||
| 3 | 3 | How raz is written here: in `src/`, `lib/`, `tools/` and `examples/`, |
| 4 | 4 | and in the programs and libraries that use them (rpg, rsqlite, rmacs, |
| 5 | 5 | ravite, ...). The report says what a program may do; this says what we |
| 6 | -do. New code keeps to it; old code comes to it when it is next changed, | |
| 7 | -or, for the library's interfaces, at a thaw (`PROPOSALS.md`). | |
| 6 | +do. New code keeps to it; old code comes to it when it is next changed. | |
| 7 | +The library came to it in report 2026-10.33. | |
| 8 | 8 | |
| 9 | 9 | ## Parameters: a value, `const`, `var`, or a pointer |
| 10 | 10 | |
| @@ -51,11 +51,3 @@ | ||
| 51 | 51 | |
| 52 | 52 | Anything else that takes `^T` and neither keeps it nor needs one of the |
| 53 | 53 | above is a mistake, and its callers' `ADR`s are noise. |
| 54 | - | |
| 55 | -## The library until a thaw | |
| 56 | - | |
| 57 | -The library's interfaces mostly take `^T` (`Buf`, `Vec`, `Map`, | |
| 58 | -`List`, `Lock`, `Opt`, ...), though none keeps what it is given. They | |
| 59 | -can't change while the freeze holds, since every caller would break; | |
| 60 | -`PROPOSALS.md` lists them for the next thaw. Until then a program | |
| 61 | -calls them with `ADR`, and its own procedures keep to this file. |
| @@ -956,7 +956,7 @@ | ||
| 956 | 956 | number from 1 to 600, not '0'`; for a number with no top, given the |
| 957 | 957 | largest `I64` for `hi`, `--jobs wants a number from 1 up, not '0'`. `refuse` refuses a value |
| 958 | 958 | the program reads itself, as `number` refuses one, naming the option as |
| 959 | -the user wrote it, `-b` or `--bar`: `Opt.refuse(ADR(p), "a label with | |
| 959 | +the user wrote it, `-b` or `--bar`: `Opt.refuse(p, "a label with | |
| 960 | 960 | no spaces")` writes `keep: -b wants a label with no spaces, not 'a b'`, |
| 961 | 961 | and the synopsis lines. `p.spelt` is that spelling, for the program's |
| 962 | 962 | own sentences. `fail` writes the program's own |
| @@ -323,6 +323,53 @@ | ||
| 323 | 323 | does, is warned of; |
| 324 | 324 | .Cm "_ := Sys.write(fd, s);" |
| 325 | 325 | says it is meant. |
| 326 | +.Pp | |
| 327 | +A record or an array that a procedure only reads goes as | |
| 328 | +.Cm const : | |
| 329 | +the caller's variable itself, read in place with nothing copied, which | |
| 330 | +the procedure can't change. | |
| 331 | +.Bd -literal -offset indent | |
| 332 | +module Grids; | |
| 333 | +import Out; | |
| 334 | + | |
| 335 | +type Grid = record cells: [64]INT; w, h: INT; end; | |
| 336 | + | |
| 337 | +proc fill(var g: Grid; v: INT); (* changes g *) | |
| 338 | +var i: INT; | |
| 339 | +begin | |
| 340 | + for i := 0 to g.w * g.h - 1 do g.cells[i] := v; end; | |
| 341 | +end; | |
| 342 | + | |
| 343 | +proc sum(const g: Grid): INT; (* reads g in place *) | |
| 344 | +var i, s: INT; | |
| 345 | +begin | |
| 346 | + s := 0; | |
| 347 | + for i := 0 to g.w * g.h - 1 do s := s + g.cells[i]; end; | |
| 348 | + return s; | |
| 349 | +end; | |
| 350 | + | |
| 351 | +proc main*; | |
| 352 | +var g: Grid; | |
| 353 | +begin | |
| 354 | + g.w := 4; | |
| 355 | + g.h := 2; | |
| 356 | + fill(g, 3); | |
| 357 | + Out.int(sum(g)); Out.ln; | |
| 358 | +end; | |
| 359 | + | |
| 360 | +end Grids. | |
| 361 | +.Ed | |
| 362 | +.Bd -literal -offset indent | |
| 363 | +24 | |
| 364 | +.Ed | |
| 365 | +.Pp | |
| 366 | +So a heading says what a procedure does with what it is given: a value | |
| 367 | +for a single value or a slice it reads, | |
| 368 | +.Cm const | |
| 369 | +for a record or an array it reads, | |
| 370 | +.Cm var | |
| 371 | +for what it changes, and a pointer only for what it keeps past the | |
| 372 | +call. | |
| 326 | 373 | .Sh 5. ARRAYS, SLICES AND STRINGS |
| 327 | 374 | .Bd -literal -offset indent |
| 328 | 375 | module Slices; |
| @@ -956,7 +1003,9 @@ | ||
| 956 | 1003 | dot; |
| 957 | 1004 | end; |
| 958 | 1005 | |
| 959 | -proc area(s: Shape): F64; | |
| 1006 | +const Some: []Shape = [circle(1.0), rect(2.0, 3.5), dot]; | |
| 1007 | + | |
| 1008 | +proc area(const s: Shape): F64; | |
| 960 | 1009 | begin |
| 961 | 1010 | match s of |
| 962 | 1011 | | circle(r): return Math.pi * r * r; |
| @@ -985,11 +1034,10 @@ | ||
| 985 | 1034 | end; |
| 986 | 1035 | |
| 987 | 1036 | proc main*; |
| 988 | -var shapes: [3]Shape; i: INT; warm: Colours; c: Colour; | |
| 1037 | +var i: INT; warm: Colours; c: Colour; | |
| 989 | 1038 | begin |
| 990 | - shapes := [circle(1.0), rect(2.0, 3.5), dot]; | |
| 991 | - for i := 0 to 2 do | |
| 992 | - Fmt.print("{}\en", [Fmt.real(area(shapes[i]), 2)]); | |
| 1039 | + for i := 0 to LEN(Some) - 1 do | |
| 1040 | + Fmt.print("{}\en", [Fmt.real(area(Some[i]), 2)]); | |
| 993 | 1041 | end; |
| 994 | 1042 | Fmt.print("{} {} {}\en", [Fmt.str(kind('7')), Fmt.str(kind('x')), |
| 995 | 1043 | Fmt.str(kind('+'))]); |
| @@ -1031,6 +1079,11 @@ | ||
| 1031 | 1079 | .Cm match |
| 1032 | 1080 | is the only way to read them: it runs the arm of the case the variant |
| 1033 | 1081 | holds, naming its fields. |
| 1082 | +A constant may hold variants, each a case built from constants, as | |
| 1083 | +.Cm Some | |
| 1084 | +does; a | |
| 1085 | +.Cm match | |
| 1086 | +on one names fields that are only read. | |
| 1034 | 1087 | Every case has an arm, unless an |
| 1035 | 1088 | .Cm "| else:" |
| 1036 | 1089 | comes last. |
| @@ -1269,6 +1322,8 @@ | ||
| 1269 | 1322 | .It "malloc(sizeof *p)" Ta "new(p)" Ta "NEW(p, Heap.heap)" |
| 1270 | 1323 | .It "free(p)" Ta "dispose(p)" Ta "Mem.free(Heap.heap, ^U8(p))" |
| 1271 | 1324 | .It "int f(int *out)" Ta "function f(var x)" Ta "proc f: (INT, INT);" |
| 1325 | +.It "void f(T *p)" Ta "procedure f(var p: T)" Ta "proc f(var p: T);" | |
| 1326 | +.It "f(const T *p)" Ta "procedure f(const p: T)" Ta "proc f(const p: T);" | |
| 1272 | 1327 | .It "return -1; errno" Ta "exceptions" Ta "return 0, NotFound;" |
| 1273 | 1328 | .It "(void)f(x);" Ta "f(x);" Ta "_ := f(x);" |
| 1274 | 1329 | .It "goto cleanup;" Ta "try ... finally" Ta "defer close(fd);" |
| @@ -48,8 +48,6 @@ | ||
| 48 | 48 | instead (the library volume), which breaks a program that calls them |
| 49 | 49 | with `ADR`. |
| 50 | 50 | |
| 51 | -The compiler follows version 2026-10.32 until the library has moved. | |
| 52 | - | |
| 53 | 51 | The language is frozen, softly, from this version on: it changes only |
| 54 | 52 | to mend a defect, and its library grows only by what breaks no program |
| 55 | 53 | written for it. What anyone wishes it had waits on a list, for a later |
| @@ -31,7 +31,7 @@ | ||
| 31 | 31 | import Sys, Out, Version, Files, Fmt, Diag, Scan, Sym, Chunk, X64, Gen, Parse, Link, Elf; |
| 32 | 32 | |
| 33 | 33 | const |
| 34 | - Report = "2026-10.32"; (* the version of doc/raz.md it follows *) | |
| 34 | + Report = "2026-10.33"; (* the version of doc/raz.md it follows *) | |
| 35 | 35 | MemfdCreate = 319; (* the system call *) |
| 36 | 36 | MfdCloexec = 1; (* an ELF still executes: the kernel opens it first *) |
| 37 | 37 | Execve = 59; |