raz / commit 9dd75230

commit
9dd7523089bc3de6453ff8288918a2a56d1db7dd
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
aeb43a7c
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.

patch · log

1 file changed, +23 -7

doc/raz.md (history) modified +23 -7

@@ -9,7 +9,7 @@
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.13 of the report; section 12 says what each
12+This is version 2026-10.14 of the report; section 12 says what each
1313 version changed. 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
@@ -51,7 +51,8 @@
5151
5252 **Identifiers** are an ASCII letter or `_` followed by letters, digits
5353 and `_`, up to 63 characters. Case matters: `count` and `Count` are different
54-names.
54+names. `_` alone isn't a name: it is the blank, which stands only to
55+the left of `:=` (section 7.1).
5556
5657 **Reserved words** are lowercase, except `VOLATILE`:
5758
@@ -795,7 +796,8 @@
795796 ```
796797 Statements = { Statement ";" } .
797798 Statement = Designator [ ":=" Expr ]
798- | Designator "," Designator { "," Designator } ":=" Expr
799+ | "_" ":=" Expr
800+ | Target "," Target { "," Target } ":=" Expr
799801 | "if" Expr "then" Statements
800802 { "elsif" Expr "then" Statements } [ "else" Statements ] "end"
801803 | "while" Expr "do" Statements "end"
@@ -808,6 +810,7 @@
808810 Arm = ( ident [ "(" ident { "," ident } ")" ]
809811 | Label { "," Label } | "else" ) ":" Statements .
810812 Label = Expr [ ".." Expr ] .
813+Target = Designator | "_" .
811814 ```
812815
813816 Every statement ends in `;`, including the ones that end in `end` or
@@ -822,6 +825,13 @@
822825 `a, b := f(x);` assigns the results of a procedure that returns several
823826 (section 8), in order.
824827
828+The blank, `_`, drops what would be assigned to it: `_ := e;`
829+evaluates `e` and drops it, and `n, _ := f(x);` keeps the first
830+result and drops the second. What is dropped is still evaluated as
831+any expression is: its calls are made, and a volatile variable in it
832+is read (section 7.6). A result dropped by a call standing on its own
833+is warned of (section 10); one dropped through `_` isn't.
834+
825835 ### 7.2 Conditions and loops
826836
827837 `if`, `while` and `repeat` take `BOOL` expressions. `repeat` runs its
@@ -1181,9 +1191,10 @@
11811191 The compiler also warns of what is declared and never used: an import;
11821192 a constant, type, variable or procedure that isn't exported; a
11831193 parameter of a procedure written in raz. It warns of a variable that is
1184-assigned but never read, too. A name that starts with `_` is never
1185-warned about. Warnings don't stop the compile; `raz -Werror` makes them
1186-errors.
1194+assigned but never read, too, and of a call standing on its own that
1195+drops a result, as `Sys.write(fd, s);` does: `_ := Sys.write(fd, s);`
1196+says it is meant. A name that starts with `_` is never warned about.
1197+Warnings don't stop the compile; `raz -Werror` makes them errors.
11871198
11881199 ## 11. The library
11891200
@@ -1879,6 +1890,9 @@
18791890 them on demand (sections 10 and 11).
18801891 - **2026-10.13.** `Sys` gains writing without waiting, and waiting for
18811892 room to write (section 11).
1893+- **2026-10.14.** The blank, `_`, drops a value or one of several
1894+ results (section 7.1); a call that drops a result is warned of
1895+ (section 10).
18821896
18831897 ## Appendix A. What an implementation chooses
18841898
@@ -2011,7 +2025,8 @@
20112025
20122026 Statements = { Statement ";" } .
20132027 Statement = Designator [ ":=" Expr ]
2014- | Designator "," Designator { "," Designator } ":=" Expr
2028+ | "_" ":=" Expr
2029+ | Target "," Target { "," Target } ":=" Expr
20152030 | "if" Expr "then" Statements
20162031 { "elsif" Expr "then" Statements } [ "else" Statements ] "end"
20172032 | "while" Expr "do" Statements "end"
@@ -2024,6 +2039,7 @@
20242039 Arm = ( ident [ "(" ident { "," ident } ")" ]
20252040 | Label { "," Label } | "else" ) ":" Statements .
20262041 Label = Expr [ ".." Expr ] .
2042+Target = Designator | "_" .
20272043
20282044 ProcDeclaration = "proc" IdentDef Signature ";"
20292045 ( "forward" | { LocalDeclaration } "begin" Statements "end" [ ident ]