raz / commit fab3f109

commit
fab3f109ca3e9ecaf5f2fbcdee62b9218dbd7c7d
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
1cef5331
Report 2026-10.10: records are their own types; failures stop everywhere

The report follows the compiler: a record, variant or enumeration is
a type of its own wherever it is written. A nil pointer, a division
by zero and a stack overflow stop the program on every target, by the
machine or by checks in the code. Fmt leaves the core. The plan takes
the owner's choices: read-only exports, atomics on words, assembly
procedures, a listing, the trap report and a profiler; no freeze for
this work.

patch · log

2 files changed, +42 -11

PLAN.md (history) modified +22 -3

@@ -66,8 +66,8 @@
6666
6767 ## Proposed, v0.6.0: raz to be rebuilt by anyone
6868
69-Not started; it waits for the owner's go-ahead, and it lifts the
70-freeze for what it names, and nothing else.
69+Under way: step 1 is in review. The freeze doesn't hold for this
70+work, by the owner's word.
7171
7272 **For:** a language a person alone can implement again, from the
7373 report, on any machine, in weeks; programs that run on small machines
@@ -97,7 +97,10 @@
9797 `LEN`, indexes, sizes and `p - q` give, and through which
9898 integers and pointers convert (the owner's choices), and how
9999 they convert to and from `I64`; a module's own choice to leave
100- out its checks of indexes and slices; reals a
100+ out its checks of indexes and slices; exported variables read only
101+ outside their module; `CAS`, `XCHG` and `XADD` on words, not
102+ only on 8 bytes; byte order, and what a packed record promises
103+ on a machine that can't read a misaligned word; reals a
101104 target may leave out; object files, a module's interface and its
102105 IR, and a generic's instances in them, named by their arguments
103106 and the fingerprints they were built from.
@@ -116,6 +119,22 @@
116119 - [ ] 9. Object files: written for each module, read in place of its
117120 source when they are current; instances kept once each by the
118121 linker.
122+- [ ] 9a. Failures caught by the code where the machine can't: a
123+ `nil` test before a dereference or a call through a procedure
124+ value, a stack limit at each procedure's start, a zero test
125+ before a division; chosen per target.
126+- [ ] 9b. Assembly procedures in place of byte procedures: the
127+ target's own syntax (appendix A), for the instructions the
128+ encoder knows and a few of the system's, bytes for the rest.
129+- [ ] 9c. `raz -S`: each line of source with its instructions, named
130+ by the encoder as it makes them, not by a disassembler.
131+- [ ] 9d. The trap report: on a failed check or a trap, the calls
132+ under way, each with its variables by name and value, from
133+ tables the compiler writes; `Rt.trace` gives the same on
134+ demand.
135+- [ ] 9e. A profiler in `Rt`: a program run with `RAZ_PROFILE` set
136+ samples where it is, and at its end says which procedures and
137+ lines took the time.
119138 - [ ] 10. `doc/compiler.md`, README, the budget, the report's version
120139 and the compiler's; tag `v0.6.0`.
121140

doc/raz.md (history) modified +20 -8

@@ -441,8 +441,11 @@
441441 ### 5.10 Same and assignable
442442
443443 Two named types are the same only if they are the same declaration.
444-Two anonymous types are the same if they are built alike: `^I64` is
445-`^I64` wherever it is written. A named and an anonymous type are the
444+Two anonymous pointer, array, slice, set or procedure types are the
445+same if they are built alike: `^I64` is `^I64` wherever it is written.
446+A record, variant or enumeration, though, is a type of its own wherever
447+it is written, named or not: two `record x: I64; end` are two types.
448+A named and an anonymous type are the
446449 same if the named one is built like the anonymous one, so that
447450 `p := ADR(n)` works for `p: NodePtr` with `type NodePtr = ^Node`.
448451 Sameness doesn't pass through the anonymous type: with `type P1 =
@@ -996,10 +999,12 @@
996999 pointer, a code procedure that breaks its rules, and C code can read or
9971000 write any memory, and what follows isn't defined. Dereferencing `nil`, dividing
9981001 by zero, calling a `nil` procedure and running out of stack stop the
999-program with a signal. Before it stops, the program prints to standard
1000-error where it was, as file, line and column, and why, as far as it can
1001-tell: a `nil` pointer, a `nil` procedure, a stack overflow, a bad
1002-address or a division fault.
1002+program, on every target. Before it stops, the program prints to
1003+standard error where it was, as file, line and column, and why, as far
1004+as it can tell: a `nil` pointer, a `nil` procedure, a stack overflow, a
1005+bad address or a division fault. Whether the machine catches these or
1006+the compiled code checks for them is the implementation's choice
1007+(appendix A); that they stop the program isn't.
10031008
10041009 **Messages.** The compiler reports an error with its file, line and
10051010 column, the line of source with the offending part underlined, and,
@@ -1518,7 +1523,10 @@
15181523 - **2026-10.10.** Said at last: what the compiler did and the report
15191524 didn't say, all through; what an implementation chooses, and the
15201525 core every target has (appendix A); the whole grammar (appendix B);
1521- the library's module names are kept for it (section 3). Mended:
1526+ the library's module names are kept for it (section 3); a record,
1527+ variant or enumeration is a type of its own wherever it is written
1528+ (section 5.10); a `nil` pointer, a division by zero and a stack
1529+ overflow stop the program on every target (section 10). Mended:
15221530 arithmetic on untyped constants that overflows is an error (section
15231531 2); a slice of a pointer can't run backwards (section 6.4). Ordinary
15241532 accesses are no longer promised to be made exactly as written, only
@@ -1543,6 +1551,10 @@
15431551 layout is the target's C layout (section 5.5).
15441552 - **The executable.** Its format, and the names and line numbers it
15451553 carries for a debugger (section 10).
1554+- **How a failure is caught.** A `nil` pointer, a division by zero or
1555+ a stack overflow may be caught by the machine or by checks in the
1556+ compiled code; either way the program stops with its message
1557+ (section 10).
15461558 - **Messages and warnings.** The text of the compiler's messages, how
15471559 many errors it reports before it stops, and which warnings it gives
15481560 (section 10). A program that is an error in this report is one in
@@ -1554,7 +1566,7 @@
15541566 give: `Sys` past writing, ending the program and getting memory,
15551567 `Thread`, `link` and `extern`. What it must have, besides the whole
15561568 language, is the core of the library: `Rt`, `Out`, `Mem`, `Arena`,
1557-`Lock`, `Str`, `Buf` and `Fmt`, and of `Sys` what they need. A
1569+`Lock`, `Str` and `Buf`, and of `Sys` what they need. A
15581570 program that keeps to the core runs on every target.
15591571
15601572 ## Appendix B. The grammar