raz / commit 7849597f

commit
7849597f2b1d4035fd36e4411a0fffdd42cbd952
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
60ab0004
raz.md: INT(b), a BOOL as an integer

patch · log

2 files changed, +10 -4

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

@@ -52,7 +52,7 @@
5252 rotated (sections 6.1 and 6.8); it breaks no program. 2026-10.36 is a
5353 twelfth: `MIN(T)` and `MAX(T)`, the limits of an integer type, and
5454 `CLZ`, `CTZ` and `POPCOUNT`, which count bits (sections 6.1 and 6.8);
55-it breaks no program.
55+and `INT(b)`, a `BOOL` as an integer (section 6.7); it breaks no program.
5656
5757 The language is frozen, softly, from this version on: it changes only
5858 to mend a defect, and its library grows only by what breaks no program
@@ -939,18 +939,21 @@
939939 | `F64` | `F32` | the nearest `F32`; too big a value gives an infinity |
940940 | enumeration | integer | its position |
941941 | integer | enumeration | the name at that position; a position out of range is a failed check (6.5), and in a constant an error |
942+| `BOOL` | integer | 0 for `false`, 1 for `true` |
942943 | set | integer | its bits |
943944 | integer | set | the low bits, as many as the set has |
944945 | `INT`, `UINT` | pointer, procedure | the address |
945946 | pointer, procedure | `INT`, `UINT` | the address |
946947 | pointer, procedure | pointer, procedure | the same address, seen as the new type |
947948
948-There are no others: no conversion between `BOOL` and integers, none
949-between pointers and integers other than `INT` and `UINT`, and none to
949+There are no others: none from an integer to `BOOL` (`x # 0` says it),
950+none between pointers and integers other than `INT` and `UINT`, and none to
950951 or from records, arrays, slices, variants or `ERROR`. An untyped integer constant converts to a pointer as an `INT` does, as
951952 in `^VOLATILE U32(0FEE00000H)`; it isn't assigned to a pointer without
952953 the conversion. A conversion of a constant is made by the compiler, by
953-the same rules: `U8(300)` is 44.
954+the same rules: `U8(300)` is 44. `U64(a = b)` is 0 or 1, and
955+`0 - U64(a = b)` is a mask; this is how a comparison is used with no
956+`if`.
954957
955958 ### 6.8 Built-in procedures
956959

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

@@ -240,3 +240,6 @@
240240 bits (or members of a set) of a word of an unsigned integer type, an
241241 `INT`, and of constants are a constant (sections 4, 6.1 and 6.8). A
242242 predeclared name may be hidden (section 2), so it breaks no program.
243+ A `BOOL` also converts to an integer, 0 for `false` and 1 for `true`
244+ (6.7), a constant too; there is still none from an integer to a
245+ `BOOL`. It breaks no program.