| | @@ -13,7 +13,7 @@ |
| 13 | 13 | This report defines the language. It is short on purpose. Whatever it |
| 14 | 14 | doesn't allow, raz doesn't have. |
| 15 | 15 | |
| 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 |
| 17 | 17 | version's changes are told. 2026-10.11 and 2026-10.12 are a thaw the owner chose, |
| 18 | 18 | for a language anyone can build again. They break programs written |
| 19 | 19 | for 2026-10.10 and before: for 2026-10.9, say, the report of compiler |
| | @@ -48,6 +48,8 @@ |
| 48 | 48 | instead (the library volume), which breaks a program that calls them |
| 49 | 49 | with `ADR`. 2026-10.34 is a tenth: `PTR(s)`, the address a slice |
| 50 | 50 | 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. |
| 51 | 53 | |
| 52 | 54 | The language is frozen, softly, from this version on: it changes only |
| 53 | 55 | to mend a defect, and its library grows only by what breaks no program |
| | @@ -375,7 +377,7 @@ |
| 375 | 377 | |
| 376 | 378 | **Constants** are evaluated by the compiler. Their expressions use only |
| 377 | 379 | 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, |
| 379 | 381 | a real, a `BOOL`, a name of an enumeration, a set, a string, an array, |
| 380 | 382 | a record, a variant or an `ERROR`. A constant of an integer type wraps as the |
| 381 | 383 | program would: `U8(250) + 10` is 4. Dividing by zero in a constant is |
| | @@ -803,6 +805,17 @@ |
| 803 | 805 | `U8`, `0C0H shl 1` is `80H`. If `x` is an untyped constant, so is the |
| 804 | 806 | result, and it doesn't wrap: `1 shl 9` is 512, which doesn't fit a `U8`. |
| 805 | 807 | |
| 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 | + |
| 806 | 819 | Relations compare as signed or unsigned according to the type. |
| 807 | 820 | |
| 808 | 821 | ### 6.2 Booleans |
| | @@ -942,6 +955,7 @@ |
| 942 | 955 | | `CAS(p, old, new)` | if `p^ = old`, sets `p^ := new` and returns `true`; atomically | |
| 943 | 956 | | `XCHG(p, x)` | sets `p^ := x` and returns the value before, atomically | |
| 944 | 957 | | `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) | |
| 945 | 959 | | `ARGC()` | the number of command line arguments, an `INT` | |
| 946 | 960 | | `ARGV()` | the arguments, a `^^U8` (C strings) | |
| 947 | 961 | |