From fab3f109ca3e9ecaf5f2fbcdee62b9218dbd7c7d Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Sun, 11 Oct 2026 20:37:28 +0000 Subject: [PATCH] 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. --- diff --git a/PLAN.md b/PLAN.md index 3902f28..e83b316 100644 --- a/PLAN.md +++ b/PLAN.md @@ -66,8 +66,8 @@ ## Proposed, v0.6.0: raz to be rebuilt by anyone -Not started; it waits for the owner's go-ahead, and it lifts the -freeze for what it names, and nothing else. +Under way: step 1 is in review. The freeze doesn't hold for this +work, by the owner's word. **For:** a language a person alone can implement again, from the report, on any machine, in weeks; programs that run on small machines @@ -97,7 +97,10 @@ `LEN`, indexes, sizes and `p - q` give, and through which integers and pointers convert (the owner's choices), and how they convert to and from `I64`; a module's own choice to leave - out its checks of indexes and slices; reals a + out its checks of indexes and slices; exported variables read only + outside their module; `CAS`, `XCHG` and `XADD` on words, not + only on 8 bytes; byte order, and what a packed record promises + on a machine that can't read a misaligned word; reals a target may leave out; object files, a module's interface and its IR, and a generic's instances in them, named by their arguments and the fingerprints they were built from. @@ -116,6 +119,22 @@ - [ ] 9. Object files: written for each module, read in place of its source when they are current; instances kept once each by the linker. +- [ ] 9a. Failures caught by the code where the machine can't: a + `nil` test before a dereference or a call through a procedure + value, a stack limit at each procedure's start, a zero test + before a division; chosen per target. +- [ ] 9b. Assembly procedures in place of byte procedures: the + target's own syntax (appendix A), for the instructions the + encoder knows and a few of the system's, bytes for the rest. +- [ ] 9c. `raz -S`: each line of source with its instructions, named + by the encoder as it makes them, not by a disassembler. +- [ ] 9d. The trap report: on a failed check or a trap, the calls + under way, each with its variables by name and value, from + tables the compiler writes; `Rt.trace` gives the same on + demand. +- [ ] 9e. A profiler in `Rt`: a program run with `RAZ_PROFILE` set + samples where it is, and at its end says which procedures and + lines took the time. - [ ] 10. `doc/compiler.md`, README, the budget, the report's version and the compiler's; tag `v0.6.0`. diff --git a/doc/raz.md b/doc/raz.md index f38ee23..51e4040 100644 --- a/doc/raz.md +++ b/doc/raz.md @@ -441,8 +441,11 @@ ### 5.10 Same and assignable Two named types are the same only if they are the same declaration. -Two anonymous types are the same if they are built alike: `^I64` is -`^I64` wherever it is written. A named and an anonymous type are the +Two anonymous pointer, array, slice, set or procedure types are the +same if they are built alike: `^I64` is `^I64` wherever it is written. +A record, variant or enumeration, though, is a type of its own wherever +it is written, named or not: two `record x: I64; end` are two types. +A named and an anonymous type are the same if the named one is built like the anonymous one, so that `p := ADR(n)` works for `p: NodePtr` with `type NodePtr = ^Node`. Sameness doesn't pass through the anonymous type: with `type P1 = @@ -996,10 +999,12 @@ pointer, a code procedure that breaks its rules, and C code can read or write any memory, and what follows isn't defined. Dereferencing `nil`, dividing by zero, calling a `nil` procedure and running out of stack stop the -program with a signal. Before it stops, the program prints to standard -error where it was, as file, line and column, and why, as far as it can -tell: a `nil` pointer, a `nil` procedure, a stack overflow, a bad -address or a division fault. +program, on every target. Before it stops, the program prints to +standard error where it was, as file, line and column, and why, as far +as it can tell: a `nil` pointer, a `nil` procedure, a stack overflow, a +bad address or a division fault. Whether the machine catches these or +the compiled code checks for them is the implementation's choice +(appendix A); that they stop the program isn't. **Messages.** The compiler reports an error with its file, line and column, the line of source with the offending part underlined, and, @@ -1518,7 +1523,10 @@ - **2026-10.10.** Said at last: what the compiler did and the report didn't say, all through; what an implementation chooses, and the core every target has (appendix A); the whole grammar (appendix B); - the library's module names are kept for it (section 3). Mended: + the library's module names are kept for it (section 3); a record, + variant or enumeration is a type of its own wherever it is written + (section 5.10); a `nil` pointer, a division by zero and a stack + overflow stop the program on every target (section 10). Mended: arithmetic on untyped constants that overflows is an error (section 2); a slice of a pointer can't run backwards (section 6.4). Ordinary accesses are no longer promised to be made exactly as written, only @@ -1543,6 +1551,10 @@ layout is the target's C layout (section 5.5). - **The executable.** Its format, and the names and line numbers it carries for a debugger (section 10). +- **How a failure is caught.** A `nil` pointer, a division by zero or + a stack overflow may be caught by the machine or by checks in the + compiled code; either way the program stops with its message + (section 10). - **Messages and warnings.** The text of the compiler's messages, how many errors it reports before it stops, and which warnings it gives (section 10). A program that is an error in this report is one in @@ -1554,7 +1566,7 @@ give: `Sys` past writing, ending the program and getting memory, `Thread`, `link` and `extern`. What it must have, besides the whole language, is the core of the library: `Rt`, `Out`, `Mem`, `Arena`, -`Lock`, `Str`, `Buf` and `Fmt`, and of `Sys` what they need. A +`Lock`, `Str` and `Buf`, and of `Sys` what they need. A program that keeps to the core runs on every target. ## Appendix B. The grammar