| | @@ -49,7 +49,10 @@ |
| 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 | 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. |
| 52 | +rotated (sections 6.1 and 6.8); it breaks no program. 2026-10.36 is a |
| 53 | +twelfth: `MIN(T)` and `MAX(T)`, the limits of an integer type, and |
| 54 | +`CLZ`, `CTZ` and `POPCOUNT`, which count bits (sections 6.1 and 6.8); |
| 55 | +it breaks no program. |
| 53 | 56 | |
| 54 | 57 | The language is frozen, softly, from this version on: it changes only |
| 55 | 58 | to mend a defect, and its library grows only by what breaks no program |
| | @@ -377,7 +380,8 @@ |
| 377 | 380 | |
| 378 | 381 | **Constants** are evaluated by the compiler. Their expressions use only |
| 379 | 382 | literals, other constants, operators, conversions, `SIZE`, the `LEN` |
| 380 | | -of arrays and strings, `ROL` and `ROR`, and a variant's cases. A constant is an integer, |
| 383 | +of arrays and strings, `MIN`, `MAX`, `ROL`, `ROR`, `CLZ`, `CTZ`, |
| 384 | +`POPCOUNT`, and a variant's cases. A constant is an integer, |
| 381 | 385 | a real, a `BOOL`, a name of an enumeration, a set, a string, an array, |
| 382 | 386 | a record, a variant or an `ERROR`. A constant of an integer type wraps as the |
| 383 | 387 | program would: `U8(250) + 10` is 4. Dividing by zero in a constant is |
| | @@ -816,6 +820,17 @@ |
| 816 | 820 | and an `or` say only at more length: `ROR(x, 7)` is `x shr 7 | x shl |
| 817 | 821 | 25` for a `U32` `x`. |
| 818 | 822 | |
| 823 | +`CLZ(x)` and `CTZ(x)` (section 6.8) count the zero bits above the |
| 824 | +highest one in `x` and below the lowest one, and `POPCOUNT(x)` counts |
| 825 | +its one bits. `x` is of an unsigned integer type, and the result is an |
| 826 | +`INT`; for `x: U8`, `CLZ(x)` is 7 when `x` is 1, and `CLZ(x)` and |
| 827 | +`CTZ(x)` are 8 when `x` is 0. The width is the type's, as for `ROL`; an |
| 828 | +untyped constant has none, so `CLZ(1)` is an error, and `CLZ(U64(1))` |
| 829 | +is 63. `POPCOUNT(x)` may also take a set, and counts its members. |
| 830 | +`MIN(T)` and `MAX(T)` are the smallest and the largest value of the |
| 831 | +integer type `T`, untyped constants: `MAX(U8)` is 255 and `MIN(I16)` is |
| 832 | +-32768. Each of the five, given constants, is a constant (section 4). |
| 833 | + |
| 819 | 834 | Relations compare as signed or unsigned according to the type. |
| 820 | 835 | |
| 821 | 836 | ### 6.2 Booleans |
| | @@ -956,6 +971,9 @@ |
| 956 | 971 | | `XCHG(p, x)` | sets `p^ := x` and returns the value before, atomically | |
| 957 | 972 | | `XADD(p, x)` | adds `x` to `p^` and returns the value before, atomically | |
| 958 | 973 | | `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) | |
| 974 | +| `CLZ(x)`, `CTZ(x)` | the number of zero bits above the highest one in `x`, or below the lowest one, an `INT`; the width of `x`'s type if `x` is 0; `x` of an unsigned integer type | |
| 975 | +| `POPCOUNT(x)` | the number of one bits in `x`, or of members of the set `x`, an `INT`; `x` of an unsigned integer type or a set | |
| 976 | +| `MIN(T)`, `MAX(T)` | the smallest, or the largest, value of the integer type `T`, an untyped constant; any other type is an error | |
| 959 | 977 | | `ARGC()` | the number of command line arguments, an `INT` | |
| 960 | 978 | | `ARGV()` | the arguments, a `^^U8` (C strings) | |
| 961 | 979 | |