raz / commit 03a24ba7

commit
03a24ba78d01a23ada945b381c1361dc1cd0d495
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
2028817d
Report 10.22.4: trimmed; the history of versions in doc/report-history.md, implementation detail in the guide

patch · log

3 files changed, +136 -129

doc/compiler.md (history) modified +11 -1

@@ -1500,7 +1500,17 @@
15001500 - **Frames.** A deferred statement's slots stay reserved for the rest
15011501 of its procedure. A generic instance first used in a procedure, or in
15021502 a module's body, is made before that code begins (`instancesFor`).
1503-- **The executable** carries DWARF line numbers and the names of
1503+- **Heap.** Blocks of nine sizes, from 16 to 4096 bytes with their
1504+ header, each with a list of the free ones; a bigger block gets pages
1505+ of its own.
1506+- **The assembly language.** Intel's syntax as NASM writes it: the
1507+ destination first; registers by name (`rax`, `eax`, `al`, `xmm0`);
1508+ memory as `[base + index * scale + disp]`, with `byte`, `word`,
1509+ `dword` or `qword` before it where no register says the size; `lock`
1510+ before an instruction.
1511+- **The executable** holds only what can be reached from `main` and the
1512+ module bodies: unused procedures, variables and strings are left
1513+ out. It carries DWARF line numbers and the names of
15041514 procedures for gdb, and the places (`Rt.places`), which hold the
15051515 line table, DWARF's, that gdb reads and `Rt` runs.
15061516

doc/raz.md (history) modified +13 -128

@@ -9,8 +9,8 @@
99 This report defines the language. It is short on purpose. Whatever it
1010 doesn't allow, raz doesn't have.
1111
12-This is version 2026-10.21 of the report; section 12 says what each
13-version changed. 2026-10.11 and 2026-10.12 are a thaw the owner chose,
12+This is version 2026-10.21 of the report; section 12 says where each
13+version's changes are told. 2026-10.11 and 2026-10.12 are a thaw the owner chose,
1414 for a language anyone can build again. They break programs written
1515 for 2026-10.10 and before: for 2026-10.9, say, the report of compiler
1616 0.5.0, the last release before them; and 2026-10.12 breaks code
@@ -1289,11 +1289,6 @@
12891289 `Rt.trace` says on standard error the calls under way, from the one
12901290 that calls it out, each with its variables, as a program that stops
12911291 does.
1292-
1293-Only what can be reached from `main` and the module bodies goes into
1294-the executable: unused procedures, variables and strings are left out.
1295-The executable names its procedures and carries line numbers, so that
1296-gdb can stop at a line of the source and show where it is.
12971292
12981293 **Defined behaviour.** Every variable starts at zero, integers wrap,
12991294 and indexing arrays and slices is checked, so a program's behaviour is
@@ -1315,11 +1310,9 @@
13151310
13161311 **Separate compilation.** An importer depends only on a module's
13171312 interface: what it exports, as an importer sees it, never its source
1318-or its code. So a module can be compiled on its own, and a program
1319-made from modules compiled at different times. Whether an
1320-implementation does so, and into what, is its own choice (appendix
1321-A); one that does makes the same program as if every module were
1322-compiled together, and keeps one copy of each instance.
1313+or its code. An implementation that compiles modules on its own makes
1314+the same program as if every module were compiled together (appendix
1315+A).
13231316
13241317 **Errors.** A program that breaks a rule of this report that says it
13251318 is an error isn't a raz program, and an implementation must reject it:
@@ -1411,9 +1404,8 @@
14111404 proc done*(ar: ^Arena); (* its memory given back *)
14121405 ```
14131406
1414-`NEW(p, a)` calls `a^.alloc`. `Heap` keeps blocks of nine sizes, from
1415-16 to 4096 bytes with their header, each with a list of the free ones;
1416-a bigger block gets pages of its own. An arena hands out memory from
1407+`NEW(p, a)` calls `a^.alloc`. `Heap` is the general
1408+allocator. An arena hands out memory from
14171409 one block: its `free` does nothing, and `reset` forgets everything.
14181410
14191411 ```
@@ -1591,9 +1583,8 @@
15911583
15921584 `nextEntry` gives every name in the directory except `.` and `..`, in
15931585 no particular order. `rawMode` turns off what the terminal does with
1594-keys before the program reads them: echo, waiting for a whole line,
1595-Ctrl-C and Ctrl-Z as signals, Ctrl-S and Ctrl-Q as flow control, and
1596-CR to NL; and with output, NL to CR NL. A program that turns it on
1586+keys before the program reads them (echo, line editing, signals, flow
1587+control), and NL to CR NL on output. A program that turns it on
15971588 restores it before it ends: `Rt.atExit` is the place.
15981589
15991590 **Files.** `open` gives a file for what `how` asks: `reading`,
@@ -1955,111 +1946,8 @@
19551946 count: `2026-10.0`, then `2026-10.1` for the next change that month.
19561947 `raz --version` says which version the compiler follows.
19571948
1958-- **2026-10.0.** The first numbered version: the language of compiler
1959- 0.3.0.
1960-- **2026-10.1.** Messages: every error in a run, warnings of what is
1961- never used and `-Werror` (section 10); failed checks say what failed,
1962- and signals say where (sections 6.5 and 10).
1963-- **2026-10.2.** `Sys` gains files and directories, the terminal, and
1964- the environment (section 11).
1965-- **2026-10.3.** `return f(x);` passes on the several results of `f`
1966- (sections 7.3 and 8). `and`, `or` and `not` are for `BOOL`s, and
1967- bind below the relations; `&`, `|` and `~` are the operators on bits,
1968- and `xor` is for integers only (sections 2 and 6). Arrays and slices
1969- of integers, `BOOL`s, enumerations, sets and pointers compare with
1970- `=`, by code where the comparison stands, not by a call into `Rt`
1971- (section 6.5). A generic module's instance is made where it is first
1972- used, so its arguments may name types declared after the imports
1973- (section 3).
1974-- **2026-10.4.** `Sys` gains a connection to a Unix socket, waiting on
1975- several files at once, pseudo-terminals, and starting, waiting for
1976- and stopping programs (section 11).
1977-- **2026-10.5.** A module with files in more than one of the
1978- directories searched is an error, unless the first is a link to one
1979- of the others (section 3).
1980-- **2026-10.6.** `Sys.Info` says whether the path is a regular file,
1981- and whether it is a symbolic link (section 11).
1982-- **2026-10.7.** `Sys.send` writes to a socket without SIGPIPE
1983- (section 11).
1984-- **2026-10.8.** `Sys.workDir` returns the directory, with no `var`
1985- parameter (section 11).
1986-- **2026-10.9.** The language is frozen (the start of the report).
1987- `Sys` gains opening a file for any use, seeking,
1988- links, permissions and times; pipes, process groups and the
1989- terminal's foreground; signals caught on a file descriptor; clocks,
1990- sleeping and random bytes; and network sockets. `Sys.spawn` takes a
1991- `Program`, and `Sys.wait` says which program changed and how. `Str`
1992- gains UTF-8 and reading a number, `Map` removing and walking, `Fmt`
1993- reals; `Sort`, `Math`, `Files` and `Opt` are new (section 11).
1994-- **2026-10.10.** Said at last: what the compiler did and the report
1995- didn't say, all through; what an implementation chooses, and the
1996- core every target has (appendix A); the whole grammar (appendix B);
1997- the library's module names are kept for it (section 3); a record,
1998- variant or enumeration is a type of its own wherever it is written
1999- (section 5.10); a `nil` pointer, a division by zero and a stack
2000- overflow stop the program on every target (section 10); byte order
2001- is the target's, and `Str` reads and writes a fixed one (sections
2002- 5.5 and 11); `Out`'s buffer is `Sys.outSize` bytes (section 11).
2003- Changed: a field of a packed record that may be misaligned has no
2004- address and no volatile access (section 5.5). Mended:
2005- arithmetic on untyped constants that overflows is an error (section
2006- 2); a slice of a pointer can't run backwards (section 6.4). Ordinary
2007- accesses are no longer promised to be made exactly as written, only
2008- volatile and atomic ones (section 7.6).
2009-- **2026-10.11.** `INT` and `UINT`, as big as an
2010- address, are the integers of lengths, slices, pointer differences,
2011- pointer conversions, `SYSCALL` and `ARGC`; `SIZE` and a constant
2012- `LEN` are untyped; `INT` widens silently to `I64` and `UINT` to
2013- `U64`, but neither mixes with them in an expression or a `for`
2014- (sections 5, 6.1 and 7.2); `Mem.Allocator` takes `INT` sizes.
2015- Pointers, procedures, `ERROR`s, slices and variants' tags are sized
2016- by the address, and basic types aligned as the target's C aligns
2017- them (section 5). Reals are a target's to have or not (section
2018- 5.1). An exported variable can't be changed, passed by `var` or
2019- addressed outside its module, nor an array in it sliced (section 3). `check off;`
2020- leaves a module's index and slice checks out (sections 3, 6.4 and
2021- 6.5). An index of any integer type is checked by its value (6.5). A
2022- shift counts modulo its operand's width, and the smallest value of
2023- every signed type divided by -1 stops the program (6.1). Writing a
2024- string's bytes isn't defined (5.10). The atomic built-ins work on
2025- `INT`, `UINT` and pointers (6.8). An integer constant past an
2026- extern's parameters goes as an `INT` (9). An importer depends only
2027- on a module's interface, so a module can be compiled on its own;
2028- whether it is, and into what, is the implementation's (sections 3
2029- and 10; appendix A). The library takes and gives
2030- `INT` for lengths, counts, descriptors, process ids and statuses,
2031- `main`'s and `Rt.exit`'s among them, and `I32` for a character;
2032- `I64` stays for what may pass an `INT` on a small target: a file's
2033- size and position, times, and numbers read from text (section
2034- 11). An array constant has a type and is used as a variable that
2035- can't be changed; `+` joins string constants (section 4). `match`
2036- takes an integer, with constants and ranges as labels (7.4).
2037-- **2026-10.12.** A code procedure is written in the target's assembly
2038- language, not as bytes (section 8; appendix A). A program that stops
2039- says the calls under way and their variables, and `Rt.trace` says
2040- them on demand (sections 10 and 11).
2041-- **2026-10.13.** `Sys` gains writing without waiting, and waiting for
2042- room to write (section 11).
2043-- **2026-10.14.** The blank, `_`, drops a value or one of several
2044- results (section 7.1); a call that drops a result is a lint
2045- (section 10).
2046-- **2026-10.15.** `Math` gains `pow`, `ceil`, `round`, `log2`,
2047- `log10`, `tan`, `asin`, `acos` and `atan`; `Sys` gains `space`
2048- (section 11).
2049-- **2026-10.16.** Record constants, and array and record constants of
2050- records, strings, procedures and more (section 4); `Str` gains
2051- `copy` (section 11).
2052-- **2026-10.17.** `COPY` copies the elements of one array or slice to
2053- another as a block (section 6.8).
2054-- **2026-10.18.** A code procedure takes and returns slices (section
2055- 8).
2056-- **2026-10.19.** The library gains `Bytes` (section 11).
2057-- **2026-10.20.** `try`: a call of a procedure whose last result is an
2058- `ERROR`, which makes the procedure it stands in return that error
2059- when it isn't `nil` (sections 2, 5.8, 6, 7.8 and appendix B). `try`
2060- becomes a reserved word, which breaks a program with a name `try`.
2061-- **2026-10.21.** An arm of a `match` on an enumeration may name
2062- several of its names (section 7.4).
1949+The history of the versions, what each changed, is in
1950+`doc/report-history.md`.
20631951
20641952 ## Appendix A. What an implementation chooses
20651953
@@ -2094,11 +1982,8 @@
20941982 value's bytes is the target's (little-endian on x86-64).
20951983 - **The assembly language.** How a code procedure's instructions are
20961984 written (section 8). On x86-64 it is Intel's syntax, as NASM writes
2097- it: the destination first; registers by name (`rax`, `eax`, `al`,
2098- `xmm0`); memory as `[base + index * scale + disp]`, with `byte`,
2099- `word`, `dword` or `qword` before it where no register says the
2100- size; `lock` before an instruction. Which instructions it knows is
2101- the implementation's; `db` gives any others.
1985+ it, destination first. Which instructions it knows is the
1986+ implementation's; `db` gives any others.
21021987 - **Sizes in the library.** How many bytes `Out` keeps before it
21031988 writes them, `Sys.outSize` (section 11): 4 KB on Linux, fewer on a
21041989 small machine.

doc/report-history.md (history) added +112 -0

@@ -0,0 +1,112 @@
1+# The versions of the report
2+
3+What each version of the report, `doc/raz.md`, changed. A version is named
4+by the month it was made in and a count: `2026-10.0`, then `2026-10.1`
5+for the next change that month. Section numbers are those of the report
6+at the time.
7+
8+- **2026-10.0.** The first numbered version: the language of compiler
9+ 0.3.0.
10+- **2026-10.1.** Messages: every error in a run, warnings of what is
11+ never used and `-Werror` (section 10); failed checks say what failed,
12+ and signals say where (sections 6.5 and 10).
13+- **2026-10.2.** `Sys` gains files and directories, the terminal, and
14+ the environment (section 11).
15+- **2026-10.3.** `return f(x);` passes on the several results of `f`
16+ (sections 7.3 and 8). `and`, `or` and `not` are for `BOOL`s, and
17+ bind below the relations; `&`, `|` and `~` are the operators on bits,
18+ and `xor` is for integers only (sections 2 and 6). Arrays and slices
19+ of integers, `BOOL`s, enumerations, sets and pointers compare with
20+ `=`, by code where the comparison stands, not by a call into `Rt`
21+ (section 6.5). A generic module's instance is made where it is first
22+ used, so its arguments may name types declared after the imports
23+ (section 3).
24+- **2026-10.4.** `Sys` gains a connection to a Unix socket, waiting on
25+ several files at once, pseudo-terminals, and starting, waiting for
26+ and stopping programs (section 11).
27+- **2026-10.5.** A module with files in more than one of the
28+ directories searched is an error, unless the first is a link to one
29+ of the others (section 3).
30+- **2026-10.6.** `Sys.Info` says whether the path is a regular file,
31+ and whether it is a symbolic link (section 11).
32+- **2026-10.7.** `Sys.send` writes to a socket without SIGPIPE
33+ (section 11).
34+- **2026-10.8.** `Sys.workDir` returns the directory, with no `var`
35+ parameter (section 11).
36+- **2026-10.9.** The language is frozen (the start of the report).
37+ `Sys` gains opening a file for any use, seeking,
38+ links, permissions and times; pipes, process groups and the
39+ terminal's foreground; signals caught on a file descriptor; clocks,
40+ sleeping and random bytes; and network sockets. `Sys.spawn` takes a
41+ `Program`, and `Sys.wait` says which program changed and how. `Str`
42+ gains UTF-8 and reading a number, `Map` removing and walking, `Fmt`
43+ reals; `Sort`, `Math`, `Files` and `Opt` are new (section 11).
44+- **2026-10.10.** Said at last: what the compiler did and the report
45+ didn't say, all through; what an implementation chooses, and the
46+ core every target has (appendix A); the whole grammar (appendix B);
47+ the library's module names are kept for it (section 3); a record,
48+ variant or enumeration is a type of its own wherever it is written
49+ (section 5.10); a `nil` pointer, a division by zero and a stack
50+ overflow stop the program on every target (section 10); byte order
51+ is the target's, and `Str` reads and writes a fixed one (sections
52+ 5.5 and 11); `Out`'s buffer is `Sys.outSize` bytes (section 11).
53+ Changed: a field of a packed record that may be misaligned has no
54+ address and no volatile access (section 5.5). Mended:
55+ arithmetic on untyped constants that overflows is an error (section
56+ 2); a slice of a pointer can't run backwards (section 6.4). Ordinary
57+ accesses are no longer promised to be made exactly as written, only
58+ volatile and atomic ones (section 7.6).
59+- **2026-10.11.** `INT` and `UINT`, as big as an
60+ address, are the integers of lengths, slices, pointer differences,
61+ pointer conversions, `SYSCALL` and `ARGC`; `SIZE` and a constant
62+ `LEN` are untyped; `INT` widens silently to `I64` and `UINT` to
63+ `U64`, but neither mixes with them in an expression or a `for`
64+ (sections 5, 6.1 and 7.2); `Mem.Allocator` takes `INT` sizes.
65+ Pointers, procedures, `ERROR`s, slices and variants' tags are sized
66+ by the address, and basic types aligned as the target's C aligns
67+ them (section 5). Reals are a target's to have or not (section
68+ 5.1). An exported variable can't be changed, passed by `var` or
69+ addressed outside its module, nor an array in it sliced (section 3). `check off;`
70+ leaves a module's index and slice checks out (sections 3, 6.4 and
71+ 6.5). An index of any integer type is checked by its value (6.5). A
72+ shift counts modulo its operand's width, and the smallest value of
73+ every signed type divided by -1 stops the program (6.1). Writing a
74+ string's bytes isn't defined (5.10). The atomic built-ins work on
75+ `INT`, `UINT` and pointers (6.8). An integer constant past an
76+ extern's parameters goes as an `INT` (9). An importer depends only
77+ on a module's interface, so a module can be compiled on its own;
78+ whether it is, and into what, is the implementation's (sections 3
79+ and 10; appendix A). The library takes and gives
80+ `INT` for lengths, counts, descriptors, process ids and statuses,
81+ `main`'s and `Rt.exit`'s among them, and `I32` for a character;
82+ `I64` stays for what may pass an `INT` on a small target: a file's
83+ size and position, times, and numbers read from text (section
84+ 11). An array constant has a type and is used as a variable that
85+ can't be changed; `+` joins string constants (section 4). `match`
86+ takes an integer, with constants and ranges as labels (7.4).
87+- **2026-10.12.** A code procedure is written in the target's assembly
88+ language, not as bytes (section 8; appendix A). A program that stops
89+ says the calls under way and their variables, and `Rt.trace` says
90+ them on demand (sections 10 and 11).
91+- **2026-10.13.** `Sys` gains writing without waiting, and waiting for
92+ room to write (section 11).
93+- **2026-10.14.** The blank, `_`, drops a value or one of several
94+ results (section 7.1); a call that drops a result is a lint
95+ (section 10).
96+- **2026-10.15.** `Math` gains `pow`, `ceil`, `round`, `log2`,
97+ `log10`, `tan`, `asin`, `acos` and `atan`; `Sys` gains `space`
98+ (section 11).
99+- **2026-10.16.** Record constants, and array and record constants of
100+ records, strings, procedures and more (section 4); `Str` gains
101+ `copy` (section 11).
102+- **2026-10.17.** `COPY` copies the elements of one array or slice to
103+ another as a block (section 6.8).
104+- **2026-10.18.** A code procedure takes and returns slices (section
105+ 8).
106+- **2026-10.19.** The library gains `Bytes` (section 11).
107+- **2026-10.20.** `try`: a call of a procedure whose last result is an
108+ `ERROR`, which makes the procedure it stands in return that error
109+ when it isn't `nil` (sections 2, 5.8, 6, 7.8 and appendix B). `try`
110+ becomes a reserved word, which breaks a program with a name `try`.
111+- **2026-10.21.** An arm of a `match` on an enumeration may name
112+ several of its names (section 7.4).