raz / commit 51a90a63

commit
51a90a630cbd3b2e3b4634d72b3568edcc476dc4
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
b17e69bd
release
v0.19.0
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).

patch · log

7 files changed, +95 -23

CLAUDE.md modified +30 -3

@@ -83,7 +83,16 @@
8383
8484 ## Where things stand
8585
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
8796 constant typed `[]T` may be `[]`, the empty slice, as may a constant's
8897 slice part), with `Vec.pop` and `Sys.Info.links`, and a constant's
8998 slice part naming another module's array constant, a defect mended;
@@ -97,7 +106,7 @@
97106 compiler in raz, built by itself (Self, done); the seed in `seed/` is
98107 frozen, and v0.9.1 was the last release it built. The compiler takes
99108 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
101110 each version of the report changed is in `doc/report-history.md`, and
102111 what each step did is in git; don't repeat it here.
103112
@@ -111,7 +120,8 @@
111120 for it. A wish for more, the owner's or yours, goes in
112121 `PROPOSALS.md`, for a later thaw; it isn't built. Thaws happen only by the
113122 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`).
115125
116126 **The reserved words and the module names are settled.** That a word
117127 is reserved, however common (`code`, `to`, `packed`, `forward`, `set`,
@@ -274,3 +284,20 @@
274284 generic module's parameters; a generic module is warned of in its
275285 first instance only. Assigning a variable whole (`x :=`, `a, b :=`)
276286 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.

README.md (history) modified +1 -1

@@ -24,7 +24,7 @@
2424 $ examples/Hello
2525 hello, world
2626
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
2828 intermediate form, no optimizer. It writes x86-64 machine code and the
2929 ELF executable itself, with no assembler or linker, and compiles about
3030 500,000 lines a second.

STANDARDS.md (history) modified +2 -10

@@ -3,8 +3,8 @@
33 How raz is written here: in `src/`, `lib/`, `tools/` and `examples/`,
44 and in the programs and libraries that use them (rpg, rsqlite, rmacs,
55 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.
88
99 ## Parameters: a value, `const`, `var`, or a pointer
1010
@@ -51,11 +51,3 @@
5151
5252 Anything else that takes `^T` and neither keeps it nor needs one of the
5353 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.

doc/raz-lib.md (history) modified +1 -1

@@ -956,7 +956,7 @@
956956 number from 1 to 600, not '0'`; for a number with no top, given the
957957 largest `I64` for `hi`, `--jobs wants a number from 1 up, not '0'`. `refuse` refuses a value
958958 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
960960 no spaces")` writes `keep: -b wants a label with no spaces, not 'a b'`,
961961 and the synopsis lines. `p.spelt` is that spelling, for the program's
962962 own sentences. `fail` writes the program's own

doc/raz-tutorial.7 (history) modified +60 -5

@@ -323,6 +323,53 @@
323323 does, is warned of;
324324 .Cm "_ := Sys.write(fd, s);"
325325 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.
326373 .Sh 5. ARRAYS, SLICES AND STRINGS
327374 .Bd -literal -offset indent
328375 module Slices;
@@ -956,7 +1003,9 @@
9561003 dot;
9571004 end;
9581005
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;
9601009 begin
9611010 match s of
9621011 | circle(r): return Math.pi * r * r;
@@ -985,11 +1034,10 @@
9851034 end;
9861035
9871036 proc main*;
988-var shapes: [3]Shape; i: INT; warm: Colours; c: Colour;
1037+var i: INT; warm: Colours; c: Colour;
9891038 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)]);
9931041 end;
9941042 Fmt.print("{} {} {}\en", [Fmt.str(kind('7')), Fmt.str(kind('x')),
9951043 Fmt.str(kind('+'))]);
@@ -1031,6 +1079,11 @@
10311079 .Cm match
10321080 is the only way to read them: it runs the arm of the case the variant
10331081 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.
10341087 Every case has an arm, unless an
10351088 .Cm "| else:"
10361089 comes last.
@@ -1269,6 +1322,8 @@
12691322 .It "malloc(sizeof *p)" Ta "new(p)" Ta "NEW(p, Heap.heap)"
12701323 .It "free(p)" Ta "dispose(p)" Ta "Mem.free(Heap.heap, ^U8(p))"
12711324 .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);"
12721327 .It "return -1; errno" Ta "exceptions" Ta "return 0, NotFound;"
12731328 .It "(void)f(x);" Ta "f(x);" Ta "_ := f(x);"
12741329 .It "goto cleanup;" Ta "try ... finally" Ta "defer close(fd);"

doc/raz.md (history) modified +0 -2

@@ -48,8 +48,6 @@
4848 instead (the library volume), which breaks a program that calls them
4949 with `ADR`.
5050
51-The compiler follows version 2026-10.32 until the library has moved.
52-
5351 The language is frozen, softly, from this version on: it changes only
5452 to mend a defect, and its library grows only by what breaks no program
5553 written for it. What anyone wishes it had waits on a list, for a later

src/Raz.raz (history) modified +1 -1

@@ -31,7 +31,7 @@
3131 import Sys, Out, Version, Files, Fmt, Diag, Scan, Sym, Chunk, X64, Gen, Parse, Link, Elf;
3232
3333 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 *)
3535 MemfdCreate = 319; (* the system call *)
3636 MfdCloexec = 1; (* an ELF still executes: the kernel opens it first *)
3737 Execve = 59;