raz / commit 906f50f4

commit
906f50f464f6691a6fa50a647953a4919ea350e2
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
547d307f
Report 2026-10.31: INT at least 16 bits and small types widening, enumerations' names with their types, continue

A thaw. U8, I8 and I16 widen to INT, U8 and U16 to UINT, where moved;
an operator's result on them doesn't (5.1, 5.10, 6.1). An enumeration's
name may be written Type.name, and must be where its scope declares the
name again (5.7). continue ends a loop's round (7.2, 7.7, B).

patch · log

2 files changed, +97 -16

doc/raz.md (history) modified +88 -16

@@ -13,7 +13,7 @@
1313 This report defines the language. It is short on purpose. Whatever it
1414 doesn't allow, raz doesn't have.
1515
16-This is version 2026-10.30 of the report; section 11 says where each
16+This is version 2026-10.31 of the report; section 11 says where each
1717 version's changes are told. 2026-10.11 and 2026-10.12 are a thaw the owner chose,
1818 for a language anyone can build again. They break programs written
1919 for 2026-10.10 and before: for 2026-10.9, say, the report of compiler
@@ -34,7 +34,12 @@
3434 sixth thaw: an array constant typed `[]T` takes its length from its
3535 literal (section 4); it breaks no program. 2026-10.30 mends a defect:
3636 `[]` used as a slice is the empty slice, which may be returned
37-(sections 6.5 and 7.3); it breaks no program.
37+(sections 6.5 and 7.3); it breaks no program. 2026-10.31 is a seventh
38+thaw: `INT` is at least 16 bits, and `U8`, `I8` and `I16` widen to it
39+(sections 5.1, 5.10 and 6.1); an enumeration's name may be written with
40+its type, and must be where another declaration shares it (section
41+5.7); and `continue` (section 7.2), which breaks a program that has a
42+name `continue`.
3843
3944 The language is frozen, softly, from this version on: it changes only
4045 to mend a defect, and its library grows only by what breaks no program
@@ -77,10 +82,10 @@
7782 **Reserved words** are lowercase, except `VOLATILE`:
7883
7984 ```
80-and begin break by code const defer div do else elsif end extern for
81-forward if import in link match mod module not of or packed proc record
82-repeat return set shl shr then to try type until var variant VOLATILE
83-while xor
85+and begin break by code const continue defer div do else elsif end
86+extern for forward if import in link match mod module not of or packed
87+proc record repeat return set shl shr then to try type until var
88+variant VOLATILE while xor
8489 ```
8590
8691 `static`, in `link static;` (section 3), and `check` and `off`, in
@@ -437,8 +442,8 @@
437442 | `F64` | 8 | IEEE 754 double precision |
438443
439444 `INT` is the everyday integer: lengths, indexes and sizes are `INT`s.
440-It is as big as an address, so it is the integer a pointer converts
441-to (section 6.7), and a word the atomic built-ins work on (section
445+It is as big as an address, and at least 16 bits, as `UINT` is, on
446+every target; so it is the integer a pointer converts to (section 6.7), and a word the atomic built-ins work on (section
442447 6.8). `INT` and `I64` are two types, even where they have the same
443448 size: an `INT` goes silently into an `I64` wherever it meets one, in
444449 an expression too (sections 5.10 and 6.1), and an `I64` becomes an
@@ -552,6 +557,30 @@
552557 enumeration has at most 256 names and takes 1 byte; the first name is
553558 0, the next 1, and so on.
554559
560+A name of an enumeration may also be written with its type,
561+`Color.red`, and one imported with the type's module, `M.Color.red`.
562+Two enumerations of a scope may share a name, and an enumeration may
563+have a name that something else of its scope has, a constant, a
564+variable or a procedure: such a name is written with its type,
565+`Elem.bold`. Written alone, it names the one declaration of it that
566+isn't an enumeration's, if there is one, and is an error if there
567+isn't:
568+
569+```
570+type
571+ Style = (bold, italic);
572+ Elem = (para, bold, rule);
573+proc rule; (* a procedure, beside Elem's rule *)
574+...
575+s := Style.bold; e := Elem.bold; e := Elem.rule;
576+e := para; (* para is Elem's alone *)
577+rule; (* the procedure *)
578+s := bold; (* an error: write Style.bold or Elem.bold *)
579+```
580+
581+The type is never taken from where the name stands: `s := bold` is an
582+error though `s` is a `Style`.
583+
555584 `set of E`, for an enumeration `E` of at most 64 names, holds any
556585 choice of `E`'s names: bit `i` stands for the name at position `i`. It
557586 takes the smallest of 1, 2, 4 and 8 bytes that has a bit for each name,
@@ -626,7 +655,11 @@
626655 least the string's length (the rest is zero);
627656 - `A` is a procedure and `B` a procedure type with the same signature;
628657 - `A` is `INT` and `B` is `I64`, or `A` is `UINT` and `B` is `U64`,
629- which loses nothing on any target.
658+ which loses nothing on any target;
659+- `A` is `U8`, `I8` or `I16` and `B` is `INT`, or `A` is `U8` or `U16`
660+ and `B` is `UINT`, which an `INT` or a `UINT` of 16 bits holds whole,
661+ so on every target; unless the value is what an operator gives
662+ (below).
630663
631664 A string's bytes are constant. A `[]U8` or `^U8` made from a string
632665 literal, or a slice of a string constant, points at them, and writing
@@ -646,6 +679,26 @@
646679 parameter of type `I64`, and a procedure returning an `INT` isn't of a
647680 procedure type returning an `I64`.
648681
682+A `U8`, `I8` or `I16` widens to `INT`, and a `U8` or `U16` to `UINT`,
683+in the same places, as an `INT` to `I64`: assigned, passed, returned,
684+in `a, b := f(x)`, to a `for`'s bounds and `INC` and `DEC`'s step, and
685+in an expression, where it meets an `INT` or a `UINT` (section 6.1).
686+They widen only that far: a `U8` meets an `I64` only as `INT(b)` or
687+`I64(b)`. And they widen only as values that are moved: a variable, an
688+element, a field, a call's result or a conversion's. What an operator
689+gives on them doesn't: it was computed in their type, and has wrapped
690+there. With `a, b: U8` holding 200 and 100, `a + b` is 44, so
691+`n := a + b`, for an `INT` `n`, is an error; `n := INT(a) + b` is 300,
692+and says where the sum is made.
693+
694+```
695+var s: []U8; n, d: INT;
696+n := s[i]; (* an element: widens *)
697+n := n * 10 + s[i] - '0'; (* n * 10 + s[i] is an INT, and so the rest *)
698+d := s[i] - '0'; (* an error: a U8, which may have wrapped *)
699+d := INT(s[i]) - '0'; (* below '0' too, it is negative *)
700+```
701+
649702 ## 6. Expressions
650703
651704 ```
@@ -689,14 +742,16 @@
689742 Both operands of `+ - * div mod & | xor`, and of a relation, have the
690743 same integer type, or one is an untyped constant that takes the
691744 other's type, which it must fit, or one is an `INT` and the other an
692-`I64` (a `UINT` and a `U64`), and the `INT` widens to `I64` (section
693-5.10). So do `v` and `k` in `INC(v, k)` and
745+`I64` (a `UINT` and a `U64`), and the `INT` widens to `I64`, or one is
746+an `INT` and the other a `U8`, `I8` or `I16` (a `UINT` and a `U8` or
747+`U16`) that no operator gave, and it widens to `INT` (section 5.10). So do `v` and `k` in `INC(v, k)` and
694748 `DEC(v, k)`, where only `k` widens: an `I64` `k` isn't added to an
695749 `INT` `v`. The result has that type and wraps around at its width:
696750 in `U8`, `200 + 100` is `44`. A unary minus wraps too: for `x` of an
697751 unsigned type, `-x` is `0 - x`. Other integer types are never mixed,
698752 whatever their sizes: with `i: I32`, `i < LEN(s)` is an error, and
699-`i` should be an `INT`. With `pos: I64`, `pos + LEN(s)` is an `I64`.
753+`i` should be an `INT`; with `c: U8`, `c < LEN(s)` is an `INT`
754+comparison. With `pos: I64`, `pos + LEN(s)` is an `I64`.
700755
701756 Where the report asks for an integer and names no type, as an index, a
702757 slice's bound, a shift's count, a pointer's offset `i` in `p + i`, or
@@ -993,6 +1048,7 @@
9931048 | "match" Expr "of" { "|" Arm } "end"
9941049 | "return" [ Expr { "," Expr } ]
9951050 | "break"
1051+ | "continue"
9961052 | "defer" Statement
9971053 | "try" Designator .
9981054 Arm = ( ident [ "(" ident { "," ident } ")" ]
@@ -1043,8 +1099,23 @@
10431099 `i <= b`. A negative `s` is the same, the other way round.
10441100
10451101 `break` ends the innermost `while`, `repeat` or `for` it stands in,
1046-and the program goes on after it. There is no `goto`.
1102+and the program goes on after it. `continue` ends the round of the
1103+innermost one, as reaching the end of its body would: a `while` tests
1104+its condition again, a `repeat` tests its `until`, and a `for` steps
1105+its variable, or ends. There is no `goto`.
1106+
1107+A `continue` passes over the rest of the body, the step of a `while`
1108+or a `repeat` included, if it stands there: so the step comes first.
10471109
1110+```
1111+while i < LEN(t) do
1112+ ch, n := Str.decode(t[i..LEN(t)]);
1113+ i := i + n; (* before any continue *)
1114+ if ch = 0ADH then continue; end; (* a soft hyphen, passed over *)
1115+ ...
1116+end;
1117+```
1118+
10481119 ### 7.3 Return
10491120
10501121 `return e;` ends the procedure with the result `e`; `return a, b;` with
@@ -1181,7 +1252,7 @@
11811252
11821253 `defer s;` runs the statement `s` when the program leaves the statement
11831254 list the `defer` stands in: at its end, or by a `return`, or by a
1184-`break` out of it. Statements deferred in the same list run in the
1255+`break` or `continue` out of it. Statements deferred in the same list run in the
11851256 opposite order to their `defer`s, and only those whose `defer` has been
11861257 reached run.
11871258
@@ -1215,8 +1286,8 @@
12151286 ```
12161287
12171288 `return e;` evaluates `e` before the deferred statements run. A
1218-deferred statement can't contain `defer`, nor a `return`, `break` or
1219-`try` that would leave it. A failed check, `Rt.exit` and `Sys.exit` end the
1289+deferred statement can't contain `defer`, nor a `return`, `break`,
1290+`continue` or `try` that would leave it. A failed check, `Rt.exit` and `Sys.exit` end the
12201291 program without running the deferred statements still pending.
12211292
12221293 ### 7.8 Try
@@ -1705,6 +1776,7 @@
17051776 | "match" Expr "of" { "|" Arm } "end"
17061777 | "return" [ Expr { "," Expr } ]
17071778 | "break"
1779+ | "continue"
17081780 | "defer" Statement
17091781 | "try" Designator .
17101782 Arm = ( ident [ "(" ident { "," ident } ")" ]

doc/report-history.md (history) modified +9 -0

@@ -180,3 +180,12 @@
180180 slice, `ptr` `nil` and `len` 0, and no hidden variable, so it may be
181181 returned (sections 6.5 and 7.3); 7.3 had made returning it an error,
182182 which the compiler never was. It breaks no program.
183+- **2026-10.31.** A thaw, the seventh. `INT` and `UINT` are at least
184+ 16 bits on every target (section 5.1). `U8`, `I8` and `I16` widen to
185+ `INT`, and `U8` and `U16` to `UINT`, where they are moved, as an
186+ `INT` widens to `I64`; what an operator gives on them doesn't
187+ (sections 5.10 and 6.1). An enumeration's name may be written with
188+ its type, `Color.red`; two enumerations of a scope may share a name,
189+ or one share a name with another declaration, and it is then written
190+ with its type (section 5.7). `continue` ends a loop's round (sections
191+ 7.2 and 7.7). It breaks a program that has a name `continue`.