From 9dd7523089bc3de6453ff8288918a2a56d1db7dd Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Mon, 12 Oct 2026 11:44:37 +0100 Subject: [PATCH] Report 2026-10.14: the blank _ := e drops a value and n, _ := f(x) one of several results; _ alone is no longer a name. A call standing on its own that drops a result is warned of. By the owner's word, freeze or not. --- diff --git a/doc/raz.md b/doc/raz.md index b14819a..74f78a2 100644 --- a/doc/raz.md +++ b/doc/raz.md @@ -9,7 +9,7 @@ This report defines the language. It is short on purpose. Whatever it doesn't allow, raz doesn't have. -This is version 2026-10.13 of the report; section 12 says what each +This is version 2026-10.14 of the report; section 12 says what each version changed. 2026-10.11 and 2026-10.12 are a thaw the owner chose, for a language anyone can build again. They break programs written for 2026-10.10 and before: for 2026-10.9, say, the report of compiler @@ -51,7 +51,8 @@ **Identifiers** are an ASCII letter or `_` followed by letters, digits and `_`, up to 63 characters. Case matters: `count` and `Count` are different -names. +names. `_` alone isn't a name: it is the blank, which stands only to +the left of `:=` (section 7.1). **Reserved words** are lowercase, except `VOLATILE`: @@ -795,7 +796,8 @@ ``` Statements = { Statement ";" } . Statement = Designator [ ":=" Expr ] - | Designator "," Designator { "," Designator } ":=" Expr + | "_" ":=" Expr + | Target "," Target { "," Target } ":=" Expr | "if" Expr "then" Statements { "elsif" Expr "then" Statements } [ "else" Statements ] "end" | "while" Expr "do" Statements "end" @@ -808,6 +810,7 @@ Arm = ( ident [ "(" ident { "," ident } ")" ] | Label { "," Label } | "else" ) ":" Statements . Label = Expr [ ".." Expr ] . +Target = Designator | "_" . ``` Every statement ends in `;`, including the ones that end in `end` or @@ -822,6 +825,13 @@ `a, b := f(x);` assigns the results of a procedure that returns several (section 8), in order. +The blank, `_`, drops what would be assigned to it: `_ := e;` +evaluates `e` and drops it, and `n, _ := f(x);` keeps the first +result and drops the second. What is dropped is still evaluated as +any expression is: its calls are made, and a volatile variable in it +is read (section 7.6). A result dropped by a call standing on its own +is warned of (section 10); one dropped through `_` isn't. + ### 7.2 Conditions and loops `if`, `while` and `repeat` take `BOOL` expressions. `repeat` runs its @@ -1181,9 +1191,10 @@ The compiler also warns of what is declared and never used: an import; a constant, type, variable or procedure that isn't exported; a parameter of a procedure written in raz. It warns of a variable that is -assigned but never read, too. A name that starts with `_` is never -warned about. Warnings don't stop the compile; `raz -Werror` makes them -errors. +assigned but never read, too, and of a call standing on its own that +drops a result, as `Sys.write(fd, s);` does: `_ := Sys.write(fd, s);` +says it is meant. A name that starts with `_` is never warned about. +Warnings don't stop the compile; `raz -Werror` makes them errors. ## 11. The library @@ -1879,6 +1890,9 @@ them on demand (sections 10 and 11). - **2026-10.13.** `Sys` gains writing without waiting, and waiting for room to write (section 11). +- **2026-10.14.** The blank, `_`, drops a value or one of several + results (section 7.1); a call that drops a result is warned of + (section 10). ## Appendix A. What an implementation chooses @@ -2011,7 +2025,8 @@ Statements = { Statement ";" } . Statement = Designator [ ":=" Expr ] - | Designator "," Designator { "," Designator } ":=" Expr + | "_" ":=" Expr + | Target "," Target { "," Target } ":=" Expr | "if" Expr "then" Statements { "elsif" Expr "then" Statements } [ "else" Statements ] "end" | "while" Expr "do" Statements "end" @@ -2024,6 +2039,7 @@ Arm = ( ident [ "(" ident { "," ident } ")" ] | Label { "," Label } | "else" ) ":" Statements . Label = Expr [ ".." Expr ] . +Target = Designator | "_" . ProcDeclaration = "proc" IdentDef Signature ";" ( "forward" | { LocalDeclaration } "begin" Statements "end" [ ident ]