raz / commit d3ddbe6b

commit
d3ddbe6bf16251db145e437e5b085f8f5cf855cc
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
c39d3f67
Report 2026-10.35: ROL and ROR, a word rotated

The eleventh thaw, by the owner's word, from PROPOSALS.md's
"Inlining a procedure that only returns", whose sauce case asked for
a rotation of the language's own, and from rcrypto, whose SHA-256 ran
at 32 MB/s with its rotations a procedure and 80 with them written
out. ROL(x, n) and ROR(x, n) rotate x, of an unsigned integer type,
left and right by n bits modulo its width; of constants they are a
constant, and an untyped x, which has no width, is an error (sections
4, 6.1 and 6.8; raz(7)). A predeclared name may be hidden, so it
breaks no program.

For the owner's review before any code. The compiler follows
2026-10.34 until it has them, so make check's version line fails
until then, as at 2026-10.33's report.

patch · log

4 files changed, +32 -3

PROPOSALS.md modified +5 -1

@@ -916,7 +916,11 @@
916916 `Str.be32` of four bytes that only returns, or the loop unrolled where
917917 it is. A rotate of the language's own, an operator or a built-in
918918 procedure, would serve SHA, the other hashes and checksums without
919-any inlining, but it is a language change, for a thaw. On 100 MB of
919+any inlining, but it is a language change, for a thaw. **Taken into
920+the report (2026-10.35):** the built-ins `ROL(x, n)` and `ROR(x, n)`,
921+by the owner's word, for review; the compiler is next. rcrypto met the
922+same (its `RAZ-NOTES.md`): SHA-256 at 32 MB/s with `ror` a procedure,
923+80 with it written out. On 100 MB of
920924 new files `sauce commit` takes 1.2 s against the Pascal sauce's 0.7,
921925 and `verify` 0.95 s against 0.48: the hashing.
922926

doc/raz.7 (history) modified +5 -0

@@ -467,6 +467,11 @@
467467 Set, or add to,
468468 .Ar p Ns ^ ,
469469 returning the value before; atomically.
470+.It Fn ROL x n , Fn ROR x n
471+.Ar x ,
472+of an unsigned integer type, rotated left or right by
473+.Ar n
474+bits modulo its width.
470475 .It Cm FENCE
471476 A full memory barrier.
472477 .It Fn SYSCALL n x1 ...

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

@@ -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.34 of the report; section 11 says where each
16+This is version 2026-10.35 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
@@ -48,6 +48,8 @@
4848 instead (the library volume), which breaks a program that calls them
4949 with `ADR`. 2026-10.34 is a tenth: `PTR(s)`, the address a slice
5050 starts at, even an empty one (section 6.8); it breaks no program.
51+2026-10.35 is an eleventh: `ROL(x, n)` and `ROR(x, n)`, a word
52+rotated (sections 6.1 and 6.8); it breaks no program.
5153
5254 The language is frozen, softly, from this version on: it changes only
5355 to mend a defect, and its library grows only by what breaks no program
@@ -375,7 +377,7 @@
375377
376378 **Constants** are evaluated by the compiler. Their expressions use only
377379 literals, other constants, operators, conversions, `SIZE`, the `LEN`
378-of arrays and strings, and a variant's cases. A constant is an integer,
380+of arrays and strings, `ROL` and `ROR`, and a variant's cases. A constant is an integer,
379381 a real, a `BOOL`, a name of an enumeration, a set, a string, an array,
380382 a record, a variant or an `ERROR`. A constant of an integer type wraps as the
381383 program would: `U8(250) + 10` is 4. Dividing by zero in a constant is
@@ -803,6 +805,17 @@
803805 `U8`, `0C0H shl 1` is `80H`. If `x` is an untyped constant, so is the
804806 result, and it doesn't wrap: `1 shl 9` is 512, which doesn't fit a `U8`.
805807
808+`ROL(x, n)` and `ROR(x, n)` (section 6.8) rotate `x` left and right
809+by `n` bits modulo its width: the bits shifted out at one end come back
810+in at the other. For `x: U8` holding `81H`, `ROL(x, 1)` is `03H` and
811+`ROR(x, 1)` is `0C0H`. `x` is of an unsigned integer type, `U8`, `U16`,
812+`U32`, `U64` or `UINT`, and the result has its type; `n` may be of any
813+integer type. An untyped constant has no width, so `ROL(1, 3)` is an
814+error, and `ROL(U32(1), 3)` is 8. Hashes and ciphers are written with
815+rotations, which machines do in one instruction, and which two shifts
816+and an `or` say only at more length: `ROR(x, 7)` is `x shr 7 | x shl
817+25` for a `U32` `x`.
818+
806819 Relations compare as signed or unsigned according to the type.
807820
808821 ### 6.2 Booleans
@@ -942,6 +955,7 @@
942955 | `CAS(p, old, new)` | if `p^ = old`, sets `p^ := new` and returns `true`; atomically |
943956 | `XCHG(p, x)` | sets `p^ := x` and returns the value before, atomically |
944957 | `XADD(p, x)` | adds `x` to `p^` and returns the value before, atomically |
958+| `ROL(x, n)`, `ROR(x, n)` | `x` rotated left, or right, by `n` bits modulo its width; `x` of an unsigned integer type (section 6.1) |
945959 | `ARGC()` | the number of command line arguments, an `INT` |
946960 | `ARGV()` | the arguments, a `^^U8` (C strings) |
947961

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

@@ -221,3 +221,9 @@
221221 `Info` gains `seconds` and `special`, for a program that copies files
222222 whole: their times in any year, their set-user-id, set-group-id and
223223 sticky bits, and a close that fails (volume 2). It breaks no program.
224+- **2026-10.35.** A thaw, the eleventh, by the owner's word, asked for
225+ by sauce and rcrypto, whose hashes call a procedure for each
226+ rotation: `ROL(x, n)` and `ROR(x, n)` rotate a word of an unsigned
227+ integer type left and right by `n` bits modulo its width, and of
228+ constants are a constant (sections 4, 6.1 and 6.8). A predeclared
229+ name may be hidden (section 2), so it breaks no program.