| | @@ -1375,7 +1375,8 @@ |
| 1375 | 1375 | (`MSG_DONTWAIT`): -11 where `send` would wait, without making reads |
| 1376 | 1376 | non-blocking too. Met in rdbus. |
| 1377 | 1377 | - **Opening without waiting.** `nonblocking` and `closeOnExec` among |
| 1378 | | - `Access`. Opening a fifo to write waits for a reader, and a fifo |
| 1378 | + `Access`. (`closeOnExec` falls away if "Sys for files and |
| 1379 | + memory" makes it the default.) Opening a fifo to write waits for a reader, and a fifo |
| 1379 | 1380 | given where a file was expected waits for a writer. Met in mosaico, |
| 1380 | 1381 | awizo, surco, raudio. |
| 1381 | 1382 | - **A fifo.** `proc makeFifo*(path: []U8; mode: INT): INT;`. Met in |
| | @@ -1505,10 +1506,7 @@ |
| 1505 | 1506 | today, so no format changes meaning unless it already had `{2}` in it, |
| 1506 | 1507 | which printed `{2}`. |
| 1507 | 1508 | |
| 1508 | | -Open: `Fmt.real` writes its exponent `e`, the language reads only `E`, |
| 1509 | | -so a printed value can't be pasted into code (rayo). Writing `E` would |
| 1510 | | -change output a test may compare; reading `e` too would change the |
| 1511 | | -report. |
| 1509 | +Settled by "One exponent letter: `Fmt` writes `E`", below. |
| 1512 | 1510 | |
| 1513 | 1511 | ## Selectors after a `^T(e)` conversion |
| 1514 | 1512 | |
| | @@ -1679,3 +1677,1196 @@ |
| 1679 | 1677 | of `doc/compiler.md` made as short and plain as the rest; a rebase on |
| 1680 | 1678 | main (`doc/compiler.md` and `src/Raz.raz` conflict). Moss's |
| 1681 | 1679 | `RAZ_PORT.lock` then pins a commit on main. |
| 1680 | + |
| 1681 | +## Constants built from constants |
| 1682 | + |
| 1683 | +**Status.** Proposed 2026-10-22, collated from RAZ-GAPS.md. |
| 1684 | + |
| 1685 | +Three small changes to what a constant may be written with, and a defect. Each stands |
| 1686 | +alone; none changes what a program that compiles today means. |
| 1687 | + |
| 1688 | +- **A named constant as an element.** `const Y: [2]R = [X, {a: 2}]`, |
| 1689 | + with `X` a record constant, is "expected a literal of R", and so is |
| 1690 | + `[X, [3, 4]]` with `X` an array constant, and `{a: X}` for an array |
| 1691 | + field. A named integer is taken (`[N, 2]` compiles), and so is a |
| 1692 | + named array constant for a slice part (`[R1, R2]` for a `[][]INT`). |
| 1693 | + The report already allows it: the value is "a literal of constants", |
| 1694 | + and its elements may be "arrays, records and variants of these". So |
| 1695 | + this is a defect of the compiler, mended with no change to the |
| 1696 | + report: where an array, record or variant is wanted, a constant of |
| 1697 | + that type stands for its literal. Met in mgla. |
| 1698 | + **Recommendation:** take, as a defect mended. Being fixed with the |
| 1699 | + other bugs of 2026-10-22, so not for the owner to decide. |
| 1700 | + |
| 1701 | +- **A literal for a slice part.** `const T: [][]INT = [[1, 2], [3]]` |
| 1702 | + is "a constant slice is a string, an array constant of its elements |
| 1703 | + or []", and so is `{r: [1, 2]}` for a `[]INT` field. Each row must be |
| 1704 | + named first, `R1: []INT = [1, 2];`, and the table written `[R1, R2]`, |
| 1705 | + or the rows flattened into one slice walked by counts, as raudio's |
| 1706 | + Sbr test does. The proposal, one clause of 4: where a slice part is |
| 1707 | + wanted, an array literal of its element type makes an array constant |
| 1708 | + of its own, with no name, as `[]` there makes the empty slice. `[]` |
| 1709 | + stays the empty slice. Met in raudio. |
| 1710 | + **Recommendation:** take, since the named rows say nothing the |
| 1711 | + literal doesn't. |
| 1712 | + |
| 1713 | +- **An `ERROR` constant named by another.** |
| 1714 | + `const Short*: ERROR = PictBase.Short;` is "an error is made from a |
| 1715 | + string", so an interface module can't pass on the errors of the |
| 1716 | + modules under it, and its callers import a second module only to |
| 1717 | + compare. The proposal, a sentence of 5.8: an `ERROR` constant whose |
| 1718 | + value is another `ERROR` constant is that same error, not a new one, |
| 1719 | + and `Short = PictBase.Short` holds. Only a string makes a new error, |
| 1720 | + as now. Met in pict. |
| 1721 | + **Recommendation:** take, since the alternative is a second import |
| 1722 | + on every caller. |
| 1723 | + |
| 1724 | +- **A comma after the last element.** `[a, b,]` is "expected an |
| 1725 | + expression", so a table written one row a line, by hand or by a |
| 1726 | + program, treats its last row apart, and adding a row changes two |
| 1727 | + lines. The proposal, in the grammar: |
| 1728 | + |
| 1729 | + | "[" [ Expr { "," Expr } [ "," ] ] "]" |
| 1730 | + | "{" [ Element { "," Element } [ "," ] ] "}" |
| 1731 | + |
| 1732 | + for array, record and set literals alike; not for calls, parameter |
| 1733 | + lists or `match` labels. `Pretty` keeps the comma where a literal |
| 1734 | + runs over lines and drops it where it fits on one. Met in rtui. |
| 1735 | + **Recommendation:** take, since a generated table is the common case |
| 1736 | + for literals this long. |
| 1737 | + |
| 1738 | +## A record's procedure field that takes the record |
| 1739 | + |
| 1740 | +**Status.** Proposed 2026-10-22, collated from RAZ-GAPS.md. |
| 1741 | + |
| 1742 | +A record that carries its own callback can't give the callback the |
| 1743 | +record: |
| 1744 | + |
| 1745 | +``` |
| 1746 | +type Lines = record each: proc(var r: Lines; s: []U8); n: INT; end; |
| 1747 | + (* "Lines isn't declared" *) |
| 1748 | +``` |
| 1749 | + |
| 1750 | +Only the base type of a pointer may name a type declared later (4), so |
| 1751 | +the callback takes `^Lines` and is called with `ADR(l)`, which by |
| 1752 | +`STANDARDS.md` says the callee keeps it, and it doesn't. Met in znaczy. |
| 1753 | + |
| 1754 | +The proposal, a clause of 4: the type of a parameter or result of a |
| 1755 | +procedure type may also name a type declared later in the same `type` |
| 1756 | +section. A procedure value is an address whatever its signature, so |
| 1757 | +the record's size doesn't depend on it; a call through the field |
| 1758 | +comes after the section, when `Lines` is whole. Nothing that compiles |
| 1759 | +today changes. In the compiler, the pointer's forward reference |
| 1760 | +reused where a signature is read in a `type` section. |
| 1761 | + |
| 1762 | +**Recommendation:** take, since the workaround puts a false `ADR` at |
| 1763 | +every call. |
| 1764 | + |
| 1765 | +## A `match` arm names its case as everywhere else |
| 1766 | + |
| 1767 | +**Status.** Proposed 2026-10-22, collated from RAZ-GAPS.md. |
| 1768 | + |
| 1769 | +An arm takes a case written alone, or with its type when the type is |
| 1770 | +the module's own (`| K.a:`). An imported case can't be written as |
| 1771 | +everywhere else outside its module: |
| 1772 | + |
| 1773 | +``` |
| 1774 | +import Xml; |
| 1775 | +... |
| 1776 | +if x.kind = Xml.done then ... end; (* qualified here *) |
| 1777 | +match x.kind of |
| 1778 | +| Xml.done: ... (* "Xml isn't a case of Xml.Kind" *) |
| 1779 | +| Xml.Kind.text: ... (* the same *) |
| 1780 | +| done: ... (* taken: a name this module otherwise hasn't *) |
| 1781 | +``` |
| 1782 | + |
| 1783 | +The same holds for a variant's cases (`| Ev.circle(r):`). Met in |
| 1784 | +rslack, rxml and fraco. |
| 1785 | + |
| 1786 | +This is the complement of "An enumeration's name read against the type |
| 1787 | +it is given to": an arm already reads a bare name against the matched |
| 1788 | +type. The proposal, a sentence of 7.4: an arm on an enumeration or a |
| 1789 | +variant names its case alone or as it is written anywhere else, with |
| 1790 | +its type, its module, or both (`done`, `Kind.done`, `Xml.done`, |
| 1791 | +`Xml.Kind.done`), and a qualified name must be a case of the matched |
| 1792 | +type. The bare form stays, so nothing breaks. A wrong qualified name |
| 1793 | +says so: "Ev.dot isn't a case of Xml.Kind". |
| 1794 | + |
| 1795 | +**Recommendation:** take, since the natural spelling is refused with a |
| 1796 | +message that doesn't say what to write. |
| 1797 | + |
| 1798 | +## Two warnings |
| 1799 | + |
| 1800 | +**Status.** Proposed 2026-10-22, collated from RAZ-GAPS.md. |
| 1801 | + |
| 1802 | +Compiler warnings, which are the implementation's own (10, appendix |
| 1803 | +A): no change to the report, and `-Werror` builds break only where the |
| 1804 | +text is in fact doubtful. |
| 1805 | + |
| 1806 | +- **A relation of `BOOL`s beside `and` or `or`.** In raz the relations |
| 1807 | + bind tighter than `and` and `or`, so |
| 1808 | + `(b[i] = 0) # (i >= 2) and (i < 9)` is |
| 1809 | + `((b[i] = 0) # (i >= 2)) and (i < 9)`. It was meant the Pascal way, |
| 1810 | + and a test passed for the wrong reason. The warning: an `=` or `#` |
| 1811 | + whose operands are `BOOL`s, written unparenthesised as an operand of |
| 1812 | + `and` or `or`: |
| 1813 | + |
| 1814 | + a # b and c is (a # b) and c: put the # of two BOOLs in parentheses |
| 1815 | + |
| 1816 | + Comparing integers is untouched, so `i < n and a[i] # 0` stays |
| 1817 | + quiet. Met in rcrypto. |
| 1818 | + **Recommendation:** take, since the slip is silent and the fix is a |
| 1819 | + pair of parentheses. |
| 1820 | + |
| 1821 | +- **`\0` before a digit.** `"\01"` is a zero byte and `1`; a reader who |
| 1822 | + knows C reads one octal byte. Moss's keyboard table, |
| 1823 | + `"\0\01234567890-="`, cost a bug. The warning, in a string or a |
| 1824 | + character where `\0` is followed by `0` to `7`: |
| 1825 | + |
| 1826 | + \0 is a zero byte and the digit after it is itself: write \x00 to keep them apart |
| 1827 | + |
| 1828 | + Met in moss (and dwa's tests have the same text, in a comment). |
| 1829 | + **Recommendation:** take, as a few lines in `Scan` for a bug already |
| 1830 | + paid for. |
| 1831 | + |
| 1832 | +## A `BOOL` as an integer: `INT(b)` |
| 1833 | + |
| 1834 | +**Status.** Proposed 2026-10-22, collated from RAZ-GAPS.md. |
| 1835 | + |
| 1836 | +Moved here from the list of what to leave out, because three programs |
| 1837 | +met it and one of them for a reason an `if` can't serve. 6.7 says |
| 1838 | +there is no conversion between `BOOL` and integers, left out until |
| 1839 | +needed. Programs now write `8 + Ord(b)` as an `if` (raudio, surco's |
| 1840 | +Lyrcheck). Constant-time code needs a comparison as a mask with no |
| 1841 | +branch: rcrypto rebuilds each test from byte differences, |
| 1842 | +`INT((d - 1) shr 31)`, since an `if` would branch on a secret. |
| 1843 | + |
| 1844 | +The proposal, one row of 6.7's table: |
| 1845 | + |
| 1846 | +| From | To | Result | |
| 1847 | +|---|---|---| |
| 1848 | +| `BOOL` | integer | 0 for `false`, 1 for `true` | |
| 1849 | + |
| 1850 | +`U64(a = b)` is 0 or 1, and `0 - U64(a = b)` the mask. Only this way: |
| 1851 | +no integer to `BOOL` (`x # 0` says it). In a constant it folds. The |
| 1852 | +compiler has the comparison's `setcc` already, so it is computed |
| 1853 | +without a branch; the report doesn't promise that (no word of it says |
| 1854 | +anything of time), but this compiler does it. |
| 1855 | + |
| 1856 | +**Recommendation:** take, since Oberon has `ORD(b)` and a constant-time |
| 1857 | +mask has no other plain spelling. |
| 1858 | + |
| 1859 | +## Counting bits: `CLZ`, `CTZ` and `POPCOUNT` |
| 1860 | + |
| 1861 | +**Status.** Proposed 2026-10-22, collated from RAZ-GAPS.md. |
| 1862 | + |
| 1863 | +raz has `ROL` and `ROR` (report 2026-10.35) but nothing that counts |
| 1864 | +bits, so programs loop. raudio's Rice decoder finds the one bit that |
| 1865 | +ends a unary code by shifting until it meets it (`Bitio.unary`); oku's |
| 1866 | +`Grid.count` asks `d in s` for each of nine digits to learn how many a |
| 1867 | +set holds. The library meets the same three times in `Bytes`: `highest` |
| 1868 | +is a loop, the lowest set byte is found by a multiply, and `count` sums |
| 1869 | +bits by a multiply, each with a paragraph to explain it. Oberon has |
| 1870 | +none of these; C compilers, Go (`math/bits`), Rust and Zig all do, as |
| 1871 | +one instruction each on every machine raz targets. |
| 1872 | + |
| 1873 | +The proposal: three built-in procedures, beside `ROL` and `ROR` in 6.8. |
| 1874 | + |
| 1875 | +| Call | Result | |
| 1876 | +|---|---| |
| 1877 | +| `CLZ(x)` | the number of zero bits above the highest one in `x`, an `INT`; the width of `x`'s type if `x` is 0; `x` of an unsigned integer type | |
| 1878 | +| `CTZ(x)` | the number of zero bits below the lowest one in `x`, an `INT`; the width of `x`'s type if `x` is 0; `x` as for `CLZ` | |
| 1879 | +| `POPCOUNT(x)` | the number of one bits in `x`, an `INT`; `x` of an unsigned integer type, or a set, whose members it counts | |
| 1880 | + |
| 1881 | +The width is the type's, as for `ROL`: `CLZ(U8(1))` is 7, `CLZ(U64(1))` |
| 1882 | +is 63. Defining 0 rather than leaving it undefined, as C does, costs a |
| 1883 | +test where the machine's instruction doesn't give the width (x86-64's |
| 1884 | +baseline `bsr` and `bsf`); `lzcnt`, `tzcnt` and `popcnt`, which the |
| 1885 | +compiler's assembler already knows, are newer than the baseline, so |
| 1886 | +the compiler emits `bsr` or `bsf` with a test, and the multiply that |
| 1887 | +`Bytes` uses for `POPCOUNT`, unless the target says the instructions |
| 1888 | +are there. A set goes to `POPCOUNT` and not to `LEN`, which already |
| 1889 | +means a fixed number of elements and would read as the size of the |
| 1890 | +set's type. |
| 1891 | + |
| 1892 | +Why three and not one: `CLZ` is what reads a code from the top bit |
| 1893 | +down (Rice, Golomb, UTF-8's lead byte, a log base 2), `CTZ` what walks |
| 1894 | +the members of a bit mask from the bottom, and `POPCOUNT` what counts. |
| 1895 | +Each can be written from another only in a way that needs a comment. |
| 1896 | +Three words among the built-ins, which a program can't declare anyway. |
| 1897 | +It breaks nothing. |
| 1898 | + |
| 1899 | +Met in raudio, oku and the library's own `Bytes`. |
| 1900 | + |
| 1901 | +**Recommendation:** take; three one-instruction built-ins replace loops |
| 1902 | +and multiplies that each need a paragraph. |
| 1903 | + |
| 1904 | +## The bytes of a variable or a slice: `BYTES(x)` |
| 1905 | + |
| 1906 | +**Status.** Proposed 2026-10-22, collated from RAZ-GAPS.md. |
| 1907 | + |
| 1908 | +A view, `v.(T)`, reads one value from bytes, and can't be sliced, |
| 1909 | +since it has no address (6.9). So a program that has words and wants |
| 1910 | +their bytes takes an unchecked pointer: raudio writes a `[]I32` of |
| 1911 | +samples to a file through `p := ^U8(PTR(s))` and `p[0..LEN(s) * 4]` |
| 1912 | +(`Ao.bytesOf`); surco's Engcheck reads a file into a `[]I32` the same |
| 1913 | +way; rcrypto wipes each hash state through `p := ^U8(ADR(c)); |
| 1914 | +RcBytes.wipe(p[0..SIZE(Ctx)])`, with a `p` that says nothing. "Selectors |
| 1915 | +after a `^T(e)` conversion" makes the last one expression, |
| 1916 | +`^U8(ADR(c))[0..SIZE(Ctx)]`, but it stays unchecked: the length is |
| 1917 | +written by hand and nothing ties it to `c`. |
| 1918 | + |
| 1919 | +The proposal: one built-in procedure. |
| 1920 | + |
| 1921 | +| Call | Result | |
| 1922 | +|---|---| |
| 1923 | +| `BYTES(x)` | the bytes of `x` as a `[]U8`: for a slice `s: []T`, its `LEN(s) * SIZE(T)` bytes; for a variable of any other type `T`, its `SIZE(T)` bytes | |
| 1924 | + |
| 1925 | +``` |
| 1926 | +n := Sys.write(fd, BYTES(samples)); (* samples: []I32 *) |
| 1927 | +n := Sys.read(fd, BYTES(words)); (* fills words: []I32 *) |
| 1928 | +RcBytes.wipe(BYTES(c)); (* c: Ctx, all of it *) |
| 1929 | +``` |
| 1930 | + |
| 1931 | +`T` must be a type a view may take (6.9): integers, reals, pointers, |
| 1932 | +and records and arrays of these alone, the types for which any bytes |
| 1933 | +are a value. So writing through the slice can make nothing mean |
| 1934 | +nothing, which is why a `BOOL`, a set, an enumeration, a slice, a |
| 1935 | +variant or a procedure, or a record holding one, is an error. The |
| 1936 | +slice is checked as any slice is; its length comes from the type, not |
| 1937 | +from the program. A variable given to `BYTES` follows the rules for a |
| 1938 | +slice of it: a local's bytes can't be returned (7.3); a `const` |
| 1939 | +parameter, a view and a volatile variable are errors, as `ADR` of them |
| 1940 | +is; a string constant is an error, as writing its bytes isn't defined. |
| 1941 | +The bytes are in the target's order (appendix A), as a view's are. |
| 1942 | + |
| 1943 | +It is `PTR` and `SIZE` made one checked expression, about 30 lines in |
| 1944 | +the compiler. It breaks nothing. It also gives "Filling bytes: |
| 1945 | +`Bytes.fill`", below, every array of words: `Bytes.fill(BYTES(a), 0)`. |
| 1946 | + |
| 1947 | +Met in raudio, surco and rcrypto. |
| 1948 | + |
| 1949 | +**Recommendation:** take; it replaces an unchecked pointer and a |
| 1950 | +hand-written length with one checked expression. |
| 1951 | + |
| 1952 | +## Filling bytes: `Bytes.fill` |
| 1953 | + |
| 1954 | +**Status.** Proposed 2026-10-22, collated from RAZ-GAPS.md. |
| 1955 | + |
| 1956 | +`COPY` copies and `NEW` zeroes, but nothing sets the bytes of a slice |
| 1957 | +already in hand. rttf clears each glyph's raster a byte at a time |
| 1958 | +(`clear`), its `Pgm` the same for an image, a `Buf.spare` slice is |
| 1959 | +cleared by a loop, and raudio zeroes a `[576]F32` with a loop or a |
| 1960 | +helper. Pascal has `FillChar`, C `memset`. |
| 1961 | + |
| 1962 | +The proposal: library growth in `Bytes`, beside `index` and `count`. |
| 1963 | + |
| 1964 | + (* Sets every byte of s to b. *) |
| 1965 | + proc fill*(s: []U8; b: U8); |
| 1966 | + |
| 1967 | +It writes eight bytes at a time as `Bytes` reads them, and |
| 1968 | +`Bytes.x86_64.raz` may use `rep stosb`. With `BYTES`, above, an array |
| 1969 | +of words is zeroed in one statement: `Bytes.fill(BYTES(a), 0)`. A |
| 1970 | +built-in `FILL(d, x)` for any element type was weighed and left: a |
| 1971 | +value other than zero for words is rare, and a loop says it. |
| 1972 | + |
| 1973 | +It breaks nothing. It is not a wipe: an optimizer may leave out a fill |
| 1974 | +that nothing reads after, as it may any write (7.6). |
| 1975 | + |
| 1976 | +Met in rttf and raudio. |
| 1977 | + |
| 1978 | +**Recommendation:** take; one procedure for a loop every buffer-handling |
| 1979 | +program writes. |
| 1980 | + |
| 1981 | +## A slice of a `const` parameter, returned |
| 1982 | + |
| 1983 | +**Status.** Proposed 2026-10-22, collated from RAZ-GAPS.md. |
| 1984 | + |
| 1985 | +7.3 says a slice of a `var` parameter, of a module variable, or of |
| 1986 | +what a pointer points at may be returned, and says nothing of a |
| 1987 | +`const` one. rimap's `proc sectionOf(const p: Part): []U8; begin |
| 1988 | +return p.section[0..p.sectionLen]; end;` compiles and works, but the |
| 1989 | +report doesn't promise it, so rimap leaves its callers to slice the |
| 1990 | +field themselves. |
| 1991 | + |
| 1992 | +A `const` parameter is the caller's variable read in place (8), as a |
| 1993 | +`var` one is, so its slice is the caller's, not this procedure's |
| 1994 | +frame. When the argument isn't a variable it is a temporary of the |
| 1995 | +caller's statement, and a slice of it kept past that statement is |
| 1996 | +already the exception of section 10. The rule only has to say so. |
| 1997 | + |
| 1998 | +The proposal, 7.3's sentence: |
| 1999 | + |
| 2000 | +> A slice of a `var` or `const` parameter, of a module variable, or of |
| 2001 | +> what a pointer points at may be returned: none of them is this |
| 2002 | +> procedure's frame. For a `const` parameter given a temporary, the |
| 2003 | +> slice lives to the end of the caller's statement (section 8). |
| 2004 | + |
| 2005 | +Only the report changes; the compiler already accepts it. It breaks |
| 2006 | +nothing. Whether the caller may write through the slice it gets back |
| 2007 | +is the question of "A slice that can't be written: `[]const T`", which |
| 2008 | +this doesn't settle. |
| 2009 | + |
| 2010 | +Met in rimap. |
| 2011 | + |
| 2012 | +**Recommendation:** take; a sentence promises what the compiler already |
| 2013 | +does. |
| 2014 | + |
| 2015 | +## What wiping can't reach, said in appendix A |
| 2016 | + |
| 2017 | +**Status.** Proposed 2026-10-22, collated from RAZ-GAPS.md. |
| 2018 | + |
| 2019 | +A wipe through `^VOLATILE U8` is never left out (7.6), but it writes |
| 2020 | +only what the program can name. A spilled register, a statement's |
| 2021 | +temporary, a value parameter's copy and an array a call returned are |
| 2022 | +the compiler's, and stay in memory after the procedure returns, until |
| 2023 | +something else writes there. rcrypto found that its wipes can't reach |
| 2024 | +them, and nothing in the report says they exist. C has the same limit |
| 2025 | +and says nothing either; OpenSSL's `OPENSSL_cleanse`, which rnet's |
| 2026 | +`Tls.wipe` calls, wipes only what it is given. |
| 2027 | + |
| 2028 | +The proposal: a paragraph in appendix A, among what an implementation |
| 2029 | +says of itself, and no feature. |
| 2030 | + |
| 2031 | +> **Copies.** A procedure's frame may hold copies of its variables |
| 2032 | +> that the program can't name: registers saved to it, temporaries of |
| 2033 | +> its statements, its value parameters, and arrays its calls return. |
| 2034 | +> This implementation leaves them where they are when the procedure |
| 2035 | +> returns; they last until the stack is used again. A wipe (7.6) |
| 2036 | +> reaches only the variables it is given. A secret is best kept in |
| 2037 | +> one variable, passed by `var` or `const` or by pointer, never by |
| 2038 | +> value, and wiped there. |
| 2039 | + |
| 2040 | +Zeroing a frame on return, by a word on the procedure or a flag, was |
| 2041 | +weighed and left: it costs every call of such a procedure a write of |
| 2042 | +its frame, and still misses registers and the kernel's copies of a |
| 2043 | +thread's state. It breaks nothing. |
| 2044 | + |
| 2045 | +Met in rcrypto. |
| 2046 | + |
| 2047 | +**Recommendation:** take; a paragraph says a limit every program that |
| 2048 | +wipes must know. |
| 2049 | + |
| 2050 | +## Sys for files and memory |
| 2051 | + |
| 2052 | +**Status.** Proposed 2026-10-22, collated from RAZ-GAPS.md. |
| 2053 | + |
| 2054 | +Library growth, but the last item changes what `open` does, so it |
| 2055 | +needs the owner's word on whether that counts as breaking. Each item |
| 2056 | +stands alone; each is in both `Sys.raz` (the C library) and |
| 2057 | +`Sys.linux-x86_64.raz` (system calls). |
| 2058 | + |
| 2059 | +- **A file mapped to be read.** `mapFile` maps to read and write, |
| 2060 | + shared, so a file opened only to read (a dictionary that isn't the |
| 2061 | + user's to write) can't be mapped: `mmap` fails with EACCES. znaczy |
| 2062 | + makes the system call itself in a `Zmap.linux.raz` (30 lines), and |
| 2063 | + raudio's Inmem does the same. |
| 2064 | + |
| 2065 | + (* The first size bytes of the file fd, which may be open only to |
| 2066 | + read, mapped to be read only: writing there stops the program. |
| 2067 | + nil if it can't be; munmap gives them back. *) |
| 2068 | + proc mapRead*(fd, size: INT): ^U8; |
| 2069 | + |
| 2070 | + C's `mmap` with `PROT_READ` and `MAP_PRIVATE`; system call 9 with |
| 2071 | + the same. Met in znaczy, raudio. **Recommendation:** take, two |
| 2072 | + programs carry a Linux-only file for it. |
| 2073 | + |
| 2074 | +- **Memory that can't be touched.** A test that puts its input against |
| 2075 | + a guard page, so that a read one byte out of range stops it, calls |
| 2076 | + `SYSCALL(10, ...)` itself and is tied to Linux; raudio's Inmem grows |
| 2077 | + a large mapping readable a step at a time, so that the bytes never |
| 2078 | + move. |
| 2079 | + |
| 2080 | + (* Lets the pages from p, size bytes from a page boundary, be read |
| 2081 | + and written as read and write say; neither, and touching them |
| 2082 | + stops the program. 0, or minus an errno. *) |
| 2083 | + proc protect*(p: ^U8; size: INT; read, write: BOOL): INT; |
| 2084 | + |
| 2085 | + C's `mprotect`; system call 10. With `mmap` it serves raudio's |
| 2086 | + reserve too: map the most it will hold, `protect` it all to neither, |
| 2087 | + and open it as it fills. Met in rttf, raudio. **Recommendation:** |
| 2088 | + take, the one portable way to a guard page. |
| 2089 | + |
| 2090 | +- **Files closed in a program exec starts.** `pipe`, sockets and |
| 2091 | + `memFile` are closed across `exec`; a file `open` gives is not, so a |
| 2092 | + fifo mosaico holds reaches every program it starts, unasked, and it |
| 2093 | + calls `keepOnExec(fd, false)` after each open. `openMode`, `open`, |
| 2094 | + `openRead` and `create` would pass `O_CLOEXEC`, and their comments |
| 2095 | + say "closed in a program exec starts" as `pipe`'s does; |
| 2096 | + `keepOnExec(fd, true)` keeps one open. `spawn`'s `fds` are unchanged, |
| 2097 | + since `dup2` in the child clears the flag. This makes the |
| 2098 | + `closeOnExec` access in "Sys for a server" unneeded (`nonblocking` |
| 2099 | + stays). A program that hands an opened file to an exec'd one by its |
| 2100 | + number, without `fds`, must then say `keepOnExec`. Met in mosaico. |
| 2101 | + **Recommendation:** take, one rule for every descriptor Sys makes. |
| 2102 | + |
| 2103 | +## Files: what programs write over Sys |
| 2104 | + |
| 2105 | +**Status.** Proposed 2026-10-22, collated from RAZ-GAPS.md. |
| 2106 | + |
| 2107 | +Library growth that breaks no program. Each is portable, written in |
| 2108 | +`Files.raz` over procedures `Sys` already has, so neither backend nor |
| 2109 | +Moss's `Sys` grows. |
| 2110 | + |
| 2111 | +- **Writing all of it.** A `write` may be short (a pipe, a socket) or |
| 2112 | + broken by a signal, and each program carries its loop; `Files.write` |
| 2113 | + has one, but only for a whole file it creates. |
| 2114 | + |
| 2115 | + (* Writes all of s to fd, again after a short write or a signal: |
| 2116 | + 0, or minus the errno of the write that failed. *) |
| 2117 | + proc writeAll*(fd: INT; s: []U8): INT; |
| 2118 | + |
| 2119 | + `Files.write` is then written over it. Met in surco (Sjournal), and |
| 2120 | + the loop is in most programs that write to a pipe. |
| 2121 | + **Recommendation:** take, the loop every writer to a pipe needs. |
| 2122 | + |
| 2123 | +- **A path made absolute and plain.** surco makes `-r` and a playlist |
| 2124 | + absolute with an `extern` to C's `realpath(3)`; dwa's |
| 2125 | + `Docs.canonical` does `setWorkDir`, `workDir` and `setWorkDir` back, |
| 2126 | + which is wrong with threads. |
| 2127 | + |
| 2128 | + (* Adds to b the absolute path of the file at path, with no ".", |
| 2129 | + "..", or symbolic link in it: 0, or minus an errno (-2, ENOENT, |
| 2130 | + if a part of it isn't there). *) |
| 2131 | + proc realPath*(path: []U8; var b: Buf.Buf): INT; |
| 2132 | + |
| 2133 | + About 40 lines over `workDir`, `linkInfo` and `readLink`, with a |
| 2134 | + bound on links followed (-40, ELOOP). Met in surco, dwa. |
| 2135 | + **Recommendation:** take, two programs and the workaround is wrong. |
| 2136 | + |
| 2137 | +- **Removing a tree.** A sauce clone cut short leaves |
| 2138 | + `<dir>.sauce-clone`, since removing a tree is a walk of `openDir`, |
| 2139 | + `remove` and `removeDir`; a test that makes a directory to work in |
| 2140 | + has the same walk to clean up. |
| 2141 | + |
| 2142 | + (* Removes the file at path and, if it is a directory, all within |
| 2143 | + it, without following a symbolic link: 0, or minus the first |
| 2144 | + errno. *) |
| 2145 | + proc removeTree*(path: []U8): INT; |
| 2146 | + |
| 2147 | + Over `openDir`, `entryKind`, `linkInfo`, `remove` and `removeDir`, |
| 2148 | + about 30 lines. Met in sauce. **Recommendation:** take, easy to get |
| 2149 | + wrong (a link to a directory followed) and wanted by every test with |
| 2150 | + a scratch directory. |
| 2151 | + |
| 2152 | +## Sys for signals and the process |
| 2153 | + |
| 2154 | +**Status.** Proposed 2026-10-22, collated from RAZ-GAPS.md. |
| 2155 | + |
| 2156 | +Library growth that breaks no program. The first three are in both |
| 2157 | +`Sys` backends; the last is in `Rt`. |
| 2158 | + |
| 2159 | +- **Whether a signal is ignored.** A program started in the |
| 2160 | + background or under `nohup` starts with some signals ignored, and |
| 2161 | + should leave those alone, as a shell does, rather than `handle` or |
| 2162 | + `catch` them. `handle` and `ignore` don't say what was there, so |
| 2163 | + robbie asks the kernel through `rt_sigaction` in an `Rsig.linux.raz`. |
| 2164 | + |
| 2165 | + (* Whether the signal sig does nothing now, as ignore(sig, true) |
| 2166 | + or the program that started this one left it. *) |
| 2167 | + proc ignored*(sig: INT): BOOL; |
| 2168 | + |
| 2169 | + C's `sigaction` with no new action; system call 13 the same. |
| 2170 | + Independent of `keepIgnored` in "Sys for running a program", which is |
| 2171 | + about the child. Met in robbie. **Recommendation:** take, any |
| 2172 | + program that takes SIGINT or SIGHUP should ask it first. |
| 2173 | + |
| 2174 | +- **An environment variable unset or empty.** `env` gives `""` for |
| 2175 | + both, but `TZ` unset means `/etc/localtime` and `TZ=` means UTC, so |
| 2176 | + alba and rzone walk `envAt` themselves. |
| 2177 | + |
| 2178 | + (* The value of the environment variable name and true, or "" and |
| 2179 | + false if it isn't set. *) |
| 2180 | + proc findEnv*(name: []U8): ([]U8, BOOL); |
| 2181 | + |
| 2182 | + `env` stays, written over it. Met in alba, rzone, surco. |
| 2183 | + **Recommendation:** take, three programs walk `envAt` for it. |
| 2184 | + |
| 2185 | +- **How many processors.** `raztest -j` would default to it, as |
| 2186 | + `make -j$(nproc)` does, and defaults to 1; rayo makes |
| 2187 | + `SYSCALL(204)` itself. |
| 2188 | + |
| 2189 | + (* The number of processors this program may run on, at least 1. *) |
| 2190 | + proc processors*: INT; |
| 2191 | + |
| 2192 | + C's `sched_getaffinity` and `CPU_COUNT`; system call 204, counting |
| 2193 | + the bits. Moss's gives 1. Met in raztest, rayo. |
| 2194 | + **Recommendation:** take, two programs and no portable way without it. |
| 2195 | + |
| 2196 | +- **How the program ends, for `atExit`.** A procedure `Rt.atExit` |
| 2197 | + registered can't tell an end by `exit(0)` from a failed check or |
| 2198 | + `Rt.stop`, so surco's log can't note a crash. |
| 2199 | + |
| 2200 | + (* The status exit was given, while the procedures atExit |
| 2201 | + registered run; 0 before. *) |
| 2202 | + proc exitStatus*: INT; |
| 2203 | + |
| 2204 | + `Rt.exit` sets it before running them. A failed check and `stop` |
| 2205 | + both end with 2, which is enough to note a crash. Met in surco. |
| 2206 | + **Recommendation:** take, three lines and nothing else can say it. |
| 2207 | + |
| 2208 | +## Numbers in the library |
| 2209 | + |
| 2210 | +**Status.** Proposed 2026-10-22, collated from RAZ-GAPS.md. |
| 2211 | + |
| 2212 | +### An unsigned decimal reader: `Str.toU64` |
| 2213 | + |
| 2214 | +Library growth that breaks no program. `Str.toInt` stops at the largest |
| 2215 | +`I64`, so a `U64` written by `Fmt.uint`, such as a `Rand.seed` read back |
| 2216 | +from `$PROP_SEED`, needs a loop of its own (raz's own `Prop.decimal`). |
| 2217 | +`toHex` already gives a `U64`; decimal should too: |
| 2218 | + |
| 2219 | + (* s as a decimal number, digits only; false if it isn't one, or a |
| 2220 | + U64 can't hold it. *) |
| 2221 | + proc toU64*(s: []U8): (U64, BOOL); |
| 2222 | + |
| 2223 | +No sign: a `-` is no `U64`, and a `+` nobody writes. `Opt.number` |
| 2224 | +stays on `toInt`. |
| 2225 | + |
| 2226 | +Met in raz's `Prop`. |
| 2227 | + |
| 2228 | +**Recommendation:** take; it is the reader for what `Fmt.uint` writes. |
| 2229 | + |
| 2230 | +### `ABS`, and `min`, `max` and `clamp` of integers |
| 2231 | + |
| 2232 | +Library and language growth that breaks no program. `Math` is `F64` |
| 2233 | +only and there are no built-ins, so rat writes `min` and `max` in Draw, |
| 2234 | +Font, Layout and Shapes, `abs` in Shapes and `clamp` in Rat; raudio's |
| 2235 | +Tags and rabble's Remote the same; mgla and fraco each write a 4-line |
| 2236 | +`abs` of an `F64`. |
| 2237 | + |
| 2238 | +The proposal, in two parts. A built-in, as Oberon has it, for every |
| 2239 | +numeric type, since one name serves integers and reals and no |
| 2240 | +procedure can: |
| 2241 | + |
| 2242 | +| Call | Result | |
| 2243 | +|---|---| |
| 2244 | +| `ABS(x)` | `x` without its sign, of `x`'s type; for an integer, `-x` if `x < 0`, so the smallest `I64` gives itself, as `-x` does | |
| 2245 | + |
| 2246 | +And three procedures in `Math`, of `INT`, the type that indexes and |
| 2247 | +counts: |
| 2248 | + |
| 2249 | + (* The smaller of a and b. *) |
| 2250 | + proc min*(a, b: INT): INT; |
| 2251 | + (* The larger of a and b. *) |
| 2252 | + proc max*(a, b: INT): INT; |
| 2253 | + (* x, or lo if it is below lo, or hi if it is above hi. *) |
| 2254 | + proc clamp*(x, lo, hi: INT): INT; |
| 2255 | + |
| 2256 | +`MIN` and `MAX` are taken for a type's limits ("The limits of an |
| 2257 | +integer type"), so these are lower-case procedures, not built-ins. |
| 2258 | +`Math`'s opening line then says "and `min`, `max` and `clamp` of |
| 2259 | +`INT`". Left out: the same of `F64`, which no program asked for. |
| 2260 | + |
| 2261 | +Open: `ABS` touches the report (6.8's table), so it may move to |
| 2262 | +the language proposals, beside `MIN(T)` and `MAX(T)`. |
| 2263 | + |
| 2264 | +Met in rat, raudio, rabble, mgla, fraco. |
| 2265 | + |
| 2266 | +**Recommendation:** take; five programs write the same four lines. |
| 2267 | + |
| 2268 | +### `Math.tanh` |
| 2269 | + |
| 2270 | +Library growth that breaks no program. `Math`'s header leaves the |
| 2271 | +hyperbolic functions out "until a program needs them"; mgla soft-clips |
| 2272 | +its mix with tanh, written `1 - 2/(exp(2x)+1)`, which loses every digit |
| 2273 | +near 0. |
| 2274 | + |
| 2275 | + (* The hyperbolic tangent of x, from -1 to 1. *) |
| 2276 | + proc tanh*(x: F64): F64; |
| 2277 | + |
| 2278 | +fdlibm's, over a private `expm1` (which `Math.pow` and `exp` already |
| 2279 | +come close to). `sinh` and `cosh` stay left out, as the header says, |
| 2280 | +until a program needs them. |
| 2281 | + |
| 2282 | +Met in mgla. |
| 2283 | + |
| 2284 | +**Recommendation:** take; the header's own rule says when, and mgla is it. |
| 2285 | + |
| 2286 | +### Rounding a half to even: `Math.roundEven` |
| 2287 | + |
| 2288 | +Library growth that breaks no program. `Math.round` takes a half away |
| 2289 | +from 0, as C's `round` does: `round(2.5)` is 3.0. Pascal's `Round`, and |
| 2290 | +IEEE 754's default, take it to the even one, 2.0, and a program that |
| 2291 | +must give Pascal's numbers (alba's, raudio's `Sbr`) writes its own, |
| 2292 | +where the case of `x + 0.5` rounding up is easy to get wrong. |
| 2293 | + |
| 2294 | + (* The whole number nearest x; a half to the even one, as IEEE 754's |
| 2295 | + default and Pascal's Round have it. *) |
| 2296 | + proc roundEven*(x: F64): F64; |
| 2297 | + |
| 2298 | +Met in alba and raudio. |
| 2299 | + |
| 2300 | +**Recommendation:** take; two programs, and the edge cases are subtle. |
| 2301 | + |
| 2302 | +### The fewest digits that read back: `Fmt.short` |
| 2303 | + |
| 2304 | +Library growth that breaks no program. `Fmt.real(x, places)` writes a |
| 2305 | +fixed number of places; nothing writes a real as briefly as it can be |
| 2306 | +written and still read back as itself. arkusz carries 150 lines for it |
| 2307 | +(`Afmt`: base-10^9 big numbers, and the halves to the neighbouring |
| 2308 | +`F64`s); fraco writes its own decimals for a deep zoom's centre, which |
| 2309 | +needs up to 17 places; alba prints coordinates. |
| 2310 | + |
| 2311 | +A case of `Arg`: |
| 2312 | + |
| 2313 | + (* r in the fewest digits that Math.toReal reads back as r; with an |
| 2314 | + exponent below 1E-4 and from 1E15 on, as real writes one. *) |
| 2315 | + short(r: F64); |
| 2316 | + |
| 2317 | +The result is unique (Steele and White; Ryu's answer). It costs a |
| 2318 | +correctly rounded conversion, so about arkusz's 150 lines, moved into |
| 2319 | +`Fmt`; `Fmt.real` keeps its own fast path. |
| 2320 | + |
| 2321 | +Left out: arkusz's exact 17-digit expansion (`sci(x, digits)`), which |
| 2322 | +`short` makes unneeded for the round trip, and rounding the 17-digit |
| 2323 | +text again as Pascal's `Str` does, which gives `45.1603` for |
| 2324 | +`Fmt.real(45.16025, 4)` where the binary value, below the half, gives |
| 2325 | +`45.1602`: that is Pascal's double rounding, not a fault in `Fmt`. |
| 2326 | + |
| 2327 | +Met in alba, arkusz and fraco. |
| 2328 | + |
| 2329 | +**Recommendation:** take; three programs, and the hard part is the |
| 2330 | +library's to do once. |
| 2331 | + |
| 2332 | +### One exponent letter: `Fmt` writes `E` |
| 2333 | + |
| 2334 | +A change to output. `Fmt.real` writes `1.50e17`; the language reads a |
| 2335 | +real's exponent as `E` only (report section 2), so a value a program |
| 2336 | +prints can't be pasted into code (rayo). `Math.toReal` reads both. |
| 2337 | + |
| 2338 | +The proposal: `Fmt` writes `E`, as the report's own numbers are |
| 2339 | +written, `1.50E17`. Reading `e` in the compiler instead would add a |
| 2340 | +spelling to the report. A test that compares printed exponents changes |
| 2341 | +by one letter; raz's own `Fmt` test is one. |
| 2342 | + |
| 2343 | +This settles the open question in "A width in `Fmt`". |
| 2344 | + |
| 2345 | +Met in rayo. |
| 2346 | + |
| 2347 | +**Recommendation:** take; one letter for the language and its library. |
| 2348 | + |
| 2349 | +## Memory, Buf and Vec |
| 2350 | + |
| 2351 | +**Status.** Proposed 2026-10-22, collated from RAZ-GAPS.md. |
| 2352 | + |
| 2353 | +### An allocator that stops when memory runs out: `Heap.sure` |
| 2354 | + |
| 2355 | +Library growth that breaks no program. `Buf` and `Vec` stop the program |
| 2356 | +when the allocator has no room; `NEW(p, Heap.heap)` and `Mem.alloc` |
| 2357 | +give `nil`, so rat checks and stops in about a dozen places. A |
| 2358 | +procedure that allocates or stops can't be written for every `T`, but |
| 2359 | +an allocator can, and `NEW` is already generic: |
| 2360 | + |
| 2361 | + (* The heap, but running out of memory stops the program, as |
| 2362 | + Buf.add does, instead of giving nil: for NEW where nil would be |
| 2363 | + a bug nobody checks for. *) |
| 2364 | + sure*: ^Mem.Allocator; |
| 2365 | + |
| 2366 | +`NEW(p, Heap.sure)` then gives a `p` or stops, with `Rt.trace`. Its |
| 2367 | +`free` is the heap's. Ten lines, and nothing new to learn. |
| 2368 | + |
| 2369 | +Met in rat. |
| 2370 | + |
| 2371 | +**Recommendation:** take; one variable makes every `NEW` safe without a |
| 2372 | +check at each. |
| 2373 | + |
| 2374 | +### Freeing back to a mark: `Arena.mark` and `Arena.release` |
| 2375 | + |
| 2376 | +Library growth that breaks no program. `Arena` frees only everything at |
| 2377 | +once, so fdn's recursive walk, which makes a few strings per entry, |
| 2378 | +gives each back to the heap by hand. An arena that goes back to where |
| 2379 | +it stood gives one line per level: |
| 2380 | + |
| 2381 | + (* Where ar stands now, for release. *) |
| 2382 | + proc mark*(const ar: Arena): INT; |
| 2383 | + |
| 2384 | + (* Everything allocated from ar since mark m freed at once; a mark |
| 2385 | + past where it stands stops the program. *) |
| 2386 | + proc release*(var ar: Arena; m: INT); |
| 2387 | + |
| 2388 | +A mark is the arena's `used`, so each is a line. `reset` is |
| 2389 | +`release(ar, 0)`, and stays for its name. |
| 2390 | + |
| 2391 | +Met in fdn. |
| 2392 | + |
| 2393 | +**Recommendation:** take; two lines in `Arena` replace a free per string. |
| 2394 | + |
| 2395 | +### Inserting and removing in the middle of a `Vec` |
| 2396 | + |
| 2397 | +Library growth that breaks no program. dwa's edit takes lines out and |
| 2398 | +puts others in by resizing around a `COPY` by hand, twice, where the |
| 2399 | +overlapping copy's direction is the thing to get wrong. |
| 2400 | + |
| 2401 | + (* n zero elements opened at i, those from i on moved up; i from 0 |
| 2402 | + to v.len. Stops the program, as push does, if there is no room. *) |
| 2403 | + proc insert*(var v: Vec; i, n: INT); |
| 2404 | + |
| 2405 | + (* The n elements from i taken out, those after them moved down; |
| 2406 | + i + n at most v.len. *) |
| 2407 | + proc remove*(var v: Vec; i, n: INT); |
| 2408 | + |
| 2409 | +`insert` gives zeros, as `add` and `resize` do, for the caller to fill |
| 2410 | +in `all(v)[i..i + n]`. Left out: a `tryInsert`, until a program wants |
| 2411 | +one. |
| 2412 | + |
| 2413 | +Met in dwa; any editor's lines, and a list kept in order, want it. |
| 2414 | + |
| 2415 | +**Recommendation:** take; it is the one `Vec` operation that is easy to |
| 2416 | +get wrong by hand. |
| 2417 | + |
| 2418 | +## Strings, base64 and text for C |
| 2419 | + |
| 2420 | +**Status.** Proposed 2026-10-22, collated from RAZ-GAPS.md. |
| 2421 | + |
| 2422 | +### A slice of a C string, and a C string of a slice |
| 2423 | + |
| 2424 | +Library growth that breaks no program. C gives a `^U8` ending in a zero |
| 2425 | +byte (an X resource's value, a class hint's name), which awizo counts |
| 2426 | +by hand to make a `[]U8`. The other way, a path for C's `open` or |
| 2427 | +`realpath` must be followed by a zero, which callers copy into a |
| 2428 | +`[PathMax + 1]U8` by hand. |
| 2429 | + |
| 2430 | + (* The bytes at p up to its zero byte, not copied; "" for nil. *) |
| 2431 | + proc fromC*(p: ^U8): []U8; |
| 2432 | + |
| 2433 | + (* s copied into out with a zero byte after it, for C: out holds |
| 2434 | + LEN(s) + 1 bytes at least. *) |
| 2435 | + proc toC*(s, out: []U8): ^U8; |
| 2436 | + |
| 2437 | +`toC` gives `PTR(out)`, so the call reads as what C is given: |
| 2438 | +`C.realpath(Str.toC(path, room), ...)`. `out` too short stops the |
| 2439 | +program, as a slice does. Left out: a `CStr` type, which would say in |
| 2440 | +a signature that a zero follows; that is a language question, and |
| 2441 | +`Sys` takes `[]U8` already. |
| 2442 | + |
| 2443 | +Met in awizo and surco; every binding to a C library meets both. |
| 2444 | + |
| 2445 | +**Recommendation:** take; the two ends of every C call that takes or |
| 2446 | +gives text. |
| 2447 | + |
| 2448 | +### Base64 in another alphabet, unpadded |
| 2449 | + |
| 2450 | +Library growth that breaks no program. `Str.base64` has RFC 4648's |
| 2451 | +section 4 alphabet, padded. Section 5's, `-` and `_` and no padding, is |
| 2452 | +PKCE's and JWTs', and IMAP's modified UTF-7 is `,` for `/`, unpadded: |
| 2453 | +roauth carries 13 lines over `Str.base64`, rimap 40 of hand-packed |
| 2454 | +6-bit letters. "Base64 in `Str`" left this out until a program needed |
| 2455 | +it; two do. |
| 2456 | + |
| 2457 | + const |
| 2458 | + (* The alphabets of RFC 4648, sections 4 and 5. *) |
| 2459 | + Base64* = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; |
| 2460 | + Base64Url* = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; |
| 2461 | + |
| 2462 | + (* s in base64 with the 64 letters of alphabet into out, which |
| 2463 | + holds base64Size(LEN(s)) bytes at least, padded with = if pad: |
| 2464 | + the bytes written. *) |
| 2465 | + proc base64With*(s, out, alphabet: []U8; pad: BOOL): INT; |
| 2466 | + |
| 2467 | + (* s decoded as base64With wrote it, into out, which holds |
| 2468 | + (LEN(s) + 3) div 4 * 3 bytes at least: the bytes written; false |
| 2469 | + as unbase64 says, or, without pad, for a length that leaves one |
| 2470 | + letter over. *) |
| 2471 | + proc unbase64With*(s, out, alphabet: []U8; pad: BOOL): (INT, BOOL); |
| 2472 | + |
| 2473 | +`base64` and `unbase64` become `base64With(s, out, Str.Base64, true)` |
| 2474 | +and stay, for the common case. rimap passes its own alphabet. |
| 2475 | + |
| 2476 | +Met in roauth and rimap. |
| 2477 | + |
| 2478 | +**Recommendation:** take; two programs, and the existing proposal named |
| 2479 | +this as the way to grow. |
| 2480 | + |
| 2481 | +### Formatting into a caller's slice: `Fmt.into` |
| 2482 | + |
| 2483 | +Library growth that breaks no program. `Fmt.write` goes only to a |
| 2484 | +`Buf`, which needs an allocator, so a library with no heap (rxml, for |
| 2485 | +"... on line 12"; rttf and magma are the same kind) joins pieces by |
| 2486 | +hand with `Str.fromInt`. `Buf` says the core has no heap to assume; |
| 2487 | +`Fmt` should then work without one. |
| 2488 | + |
| 2489 | + (* f formatted into out as write formats it: the bytes written, and |
| 2490 | + false if out was too short and the text is cut there. *) |
| 2491 | + proc into*(out: []U8; f: []U8; args: []Arg): (INT, BOOL); |
| 2492 | + |
| 2493 | +Cut short, not stopped: the length of formatted text isn't known |
| 2494 | +before, as base64's is. Inside, `put` writes to a target that is a |
| 2495 | +`Buf`, a slice, or standard output, in place of today's `^Buf.Buf` or |
| 2496 | +`nil`. |
| 2497 | + |
| 2498 | +Met in rxml. |
| 2499 | + |
| 2500 | +**Recommendation:** take; it makes `Fmt` usable in the no-heap core |
| 2501 | +`Buf` itself is written for. |
| 2502 | + |
| 2503 | +## `Opt` |
| 2504 | + |
| 2505 | +**Status.** Proposed 2026-10-22, collated from RAZ-GAPS.md. |
| 2506 | + |
| 2507 | +### A negative number as an operand |
| 2508 | + |
| 2509 | +A change to what `Opt` reads, for scopes it can't hurt. `alba -33.87 |
| 2510 | +151.21` is "unknown option -3", and `--` changes the command line the |
| 2511 | +user types, so alba reads its arguments by hand and loses `Opt`'s help |
| 2512 | +and mistakes. |
| 2513 | + |
| 2514 | +The proposal: in a scope with no option whose letter is a digit, a |
| 2515 | +word of a `-` and then a digit is an operand, and so ends the options |
| 2516 | +as any operand does. A scope that gives a digit a letter (`head -5` |
| 2517 | +style) reads it as today. No new procedure; the library volume's list |
| 2518 | +of rules gains a line. |
| 2519 | + |
| 2520 | +Met in alba. |
| 2521 | + |
| 2522 | +**Recommendation:** take; one rule, no interface, and it lets a numeric |
| 2523 | +program keep `Opt`. |
| 2524 | + |
| 2525 | +### A mistake in the operands, with the synopsis: `Opt.misuse` |
| 2526 | + |
| 2527 | +Library growth that breaks no program. `Opt.fail` writes the program's |
| 2528 | +sentence alone, for "no command; see keep -h". The one that adds the |
| 2529 | +synopsis lines, as `Opt`'s own mistakes and `refuse` do, is the private |
| 2530 | +`mistake`, so raztest's "no tests named", a mistake in the operands, |
| 2531 | +comes without the usage a user needs. |
| 2532 | + |
| 2533 | + (* The program's own mistake, written as Opt's are, with the |
| 2534 | + scope's synopsis lines after it, and status 2. *) |
| 2535 | + proc misuse*(const p: Parser; text: []U8); |
| 2536 | + |
| 2537 | +It is `mistake` with `text` as its one argument. A flag on `fail` |
| 2538 | +would read worse at the call. |
| 2539 | + |
| 2540 | +Met in raztest. |
| 2541 | + |
| 2542 | +**Recommendation:** take; three lines, and no workaround without |
| 2543 | +copying the table's synopsis by hand. |
| 2544 | + |
| 2545 | +## A freestanding program, stated |
| 2546 | + |
| 2547 | +**Status.** Proposed 2026-10-22, collated from RAZ-GAPS.md. |
| 2548 | + |
| 2549 | +"For a kernel: three changes to the compiler" made a raz program run on |
| 2550 | +the bare machine; Moss, a kernel in raz, now boots on it. What it found |
| 2551 | +is less a missing feature than missing words: what a `-bare` program |
| 2552 | +must give the compiler, and what it may count on, are known only by |
| 2553 | +reading `Gen.entryPoint` and `Raz`. Five items, each standing alone. |
| 2554 | +The sixth thing Moss met, `jmp rax` read as a jump to a label, was a |
| 2555 | +bug, fixed in ac3c464. |
| 2556 | + |
| 2557 | +**1. The runtime ABI, written down.** A section of `doc/compiler.md`, |
| 2558 | +"A program with its own `Rt`", saying what the compiler asks of `Rt` |
| 2559 | +and what a program's start may count on: |
| 2560 | +- **Required:** `proc exit*(status: INT);`, which never returns (the |
| 2561 | + compiler puts `ud2` after its call), and |
| 2562 | + `proc fail*(what, a, b, len: INT; at: UINT; name: ^U8; rdi, rsi: UINT);`, |
| 2563 | + with the kinds of `what` as `lib/Rt.raz` gives them (0 an index, 1 a |
| 2564 | + slice, 2 an enumeration, 3 a backward slice of a pointer, 4 a nil |
| 2565 | + pointer, 5 a division by zero, 6 a stack overflow, 7 a view), named |
| 2566 | + constants in the text, not bare numbers. |
| 2567 | +- **Optional, found by name when declared:** `places`, `calls`, |
| 2568 | + `teller`, `place`, `placer` (item 5), `startProfile` and `profiler` |
| 2569 | + (never under `-bare`), `cExit` (only with C, which `-bare` refuses). |
| 2570 | +- **The entry:** `_start` runs every used module's body but `Rt`'s, |
| 2571 | + then `main`. Under `-bare` it reads nothing from the stack and aligns |
| 2572 | + nothing: the loader or boot stub enters it with the bss zeroed and |
| 2573 | + `rsp` a multiple of 16, as Linux does. |
| 2574 | +- **`main` returning:** allowed. `Rt.exit` is then called with `main`'s |
| 2575 | + result, or 0 for `proc main*`. |
| 2576 | +- **The panic hook:** `Rt.fail` is it. A kernel's `fail` prints and |
| 2577 | + halts; nothing else is needed, and no second hook is proposed. |
| 2578 | + |
| 2579 | +A test holds it: `test/run/` builds a `-bare` program against a |
| 2580 | +smallest `Rt` of `exit` and `fail` alone, run under Linux, whose |
| 2581 | +`exit` and `fail` make the system call themselves. |
| 2582 | + |
| 2583 | +Met in Moss (`docs/raz-findings.md` §2), which copied the stock |
| 2584 | +signatures. |
| 2585 | + |
| 2586 | +**Recommendation:** take; it is words and one test, and the contract |
| 2587 | +already exists. |
| 2588 | + |
| 2589 | +**2. A recipe for an interrupt's entry.** Before any attribute or |
| 2590 | +generated stub, a tested recipe in `doc/compiler.md`, beside item 1, |
| 2591 | +stating what the compiler's code may assume and so what a stub must |
| 2592 | +restore: |
| 2593 | +- **What the compiler's code uses:** System V's caller-saved |
| 2594 | + registers, `rax`, `rcx`, `rdx`, `rsi`, `rdi`, `r8` to `r11`, all of |
| 2595 | + `xmm0` to `xmm15`, and the flags; the direction flag is clear at |
| 2596 | + every call (the compiler's copies use `std` and `cld` and leave it |
| 2597 | + clear). |
| 2598 | +- **The red zone:** whether the compiler ever writes below `rsp`. Not |
| 2599 | + checked today ("For a kernel" leaves it open); it is to be checked |
| 2600 | + and the answer written down. If it never does, an interrupt needs no |
| 2601 | + IST stack for that reason. |
| 2602 | +- **The stub:** a `code` procedure per vector that pushes 0 where the |
| 2603 | + CPU pushes no error code, pushes the vector, saves the caller-saved |
| 2604 | + registers, aligns `rsp` to 16, saves the SSE state (`fxsave` or |
| 2605 | + `xsave` to an aligned area), `cld`, calls an ordinary procedure |
| 2606 | + `proc handle(vector, code: INT; frame: ^Frame)`, restores, drops the |
| 2607 | + two words and `iretq`. |
| 2608 | + |
| 2609 | +It is testable on Linux: `iretq` from ring 3 to ring 3 is allowed, so |
| 2610 | +`test/run/Interrupt.raz` builds a frame by hand, jumps to the stub, has |
| 2611 | +the handler compute with reals, and checks on return that every |
| 2612 | +register the stub promised to keep is kept. The stub needs items 3 and |
| 2613 | +"The assembler's instructions", 1 (`push` of a constant, `cld`). |
| 2614 | + |
| 2615 | +Met in Moss (`docs/raz-findings.md` §4): its handlers use only `rax` |
| 2616 | +and make no call, which is safe but no recipe. |
| 2617 | + |
| 2618 | +**Recommendation:** take; a kernel's first stub is where the calling |
| 2619 | +convention is easiest to get wrong, and a test on Linux keeps it right. |
| 2620 | + |
| 2621 | +**3. A code procedure names a procedure or a global.** In a code |
| 2622 | +procedure, a name of the module's scope, or a qualified one, that is a |
| 2623 | +procedure or a global variable stands for its address, as an operand |
| 2624 | +of three forms only: |
| 2625 | + |
| 2626 | + call fault; (* a procedure, rip-relative *) |
| 2627 | + jmp fault; |
| 2628 | + lea rax, [ticks]; (* a procedure or a global *) |
| 2629 | + |
| 2630 | +Each makes a reference to that chunk, so the linker keeps what is |
| 2631 | +named, as any call does. No other operand takes a name, and no type is |
| 2632 | +checked: a code procedure is the target's, and its author already |
| 2633 | +answers for the convention. The assembler gets the names as it gets |
| 2634 | +constants, by a function the parser hands in beside `ConstFn`. |
| 2635 | + |
| 2636 | +Moss stores `UINT(fault)` in a slot at start and calls through a |
| 2637 | +register (`docs/raz-findings.md` §5), so the slot must be filled |
| 2638 | +before the first fault, which nothing checks. |
| 2639 | + |
| 2640 | +**Recommendation:** take; three operand forms remove a hand-off that |
| 2641 | +can be forgotten, and the recipe in item 2 needs `call handle`. |
| 2642 | + |
| 2643 | +**4. A program brings its own `Rt`.** A `src/Rt.raz` beside the main |
| 2644 | +module meets `lib/Rt.raz`, and "a program has one module of each name" |
| 2645 | +refuses it, rightly. Moss copies the compiler beside an empty `lib/`. |
| 2646 | +Two ways out: |
| 2647 | +- **Staging,** as "The compiler on another host" proposes for the |
| 2648 | + compiler's own sources: copy `raz` beside a library of the program's |
| 2649 | + own. Nothing in raz changes; only words in `doc/compiler.md`. Every |
| 2650 | + freestanding project then carries a copied compiler, and its library |
| 2651 | + is all or nothing. |
| 2652 | +- **`raz -lib DIR`:** the library is `DIR`, not the one beside the |
| 2653 | + compiler. A kernel's `-lib` is a directory holding its own `Rt` and |
| 2654 | + `Sys` and, by symbolic links, whichever of raz's modules it takes |
| 2655 | + (`Str`, `Fmt`, `Buf`). The duplicate check stays as it is. On the |
| 2656 | + `Host` branch it is one line over `Host.libraryDir`; today a few |
| 2657 | + lines in `Raz.raz` and raz(1). |
| 2658 | + |
| 2659 | +The option is the smaller for its users and nearly as small in raz; |
| 2660 | +staging stays the way for the compiler on another host, where the |
| 2661 | +whole of `src/` is replaced anyway. |
| 2662 | + |
| 2663 | +**Recommendation:** take `-lib`; a few lines save every freestanding |
| 2664 | +program a copy of the compiler. |
| 2665 | + |
| 2666 | +**5. Symbols without `Rt`'s places.** Without `-s` the compiler links |
| 2667 | +`places`, `calls`, `teller`, `place` and `placer` and stops with "Rt |
| 2668 | +has no places" where `Rt` lacks one, and `-noprofile` doesn't help, so |
| 2669 | +Moss builds with `-s` and loses the symbol table a debugger reads. |
| 2670 | +Two things are tied that needn't be: the ELF's symbols and lines, for |
| 2671 | +a debugger, and the places, for `Rt` to say where a check failed. |
| 2672 | +The change: each of the five is linked only when `Rt` declares it, |
| 2673 | +`calls` with `teller` and `place` with `placer`, a pair or neither; `-s` |
| 2674 | +still strips both. A kernel then keeps its symbols for GDB and gives |
| 2675 | +`fail` the raw address, or declares `places` and decodes them itself. |
| 2676 | + |
| 2677 | +A hosted program's `Rt` is raz's, which declares all five, so no |
| 2678 | +program changes. One that writes its own `Rt` and misspells `places` |
| 2679 | +loses its places silently; item 1 lists the names. |
| 2680 | + |
| 2681 | +Met in Moss (`docs/raz-findings.md` §3). |
| 2682 | + |
| 2683 | +**Recommendation:** take; it is a test on each name in `Raz.raz` and |
| 2684 | +gives a kernel its symbols back. |
| 2685 | + |
| 2686 | +## The assembler's instructions |
| 2687 | + |
| 2688 | +**Status.** Proposed 2026-10-22, collated from RAZ-GAPS.md. |
| 2689 | + |
| 2690 | +The report leaves which instructions the assembler knows to the |
| 2691 | +implementation, and `db` gives any other. That stays. What is missing |
| 2692 | +is a rule for when an instruction joins, and the few that programs |
| 2693 | +have already written in `db`. |
| 2694 | + |
| 2695 | +**1. `push` of a constant, and `cld` and `std`.** `push imm8` and |
| 2696 | +`push imm32` (6A, 68, sign-extended to 64 bits), and `cld` and `std` |
| 2697 | +in `Plain`. The encoder already writes `cld` and `std` for the |
| 2698 | +compiler's copies; only the assembler's table lacks them. Moss's |
| 2699 | +exception stubs write all three with `db`, and every stub of |
| 2700 | +"A freestanding program, stated", 2, needs them. |
| 2701 | + |
| 2702 | +**Recommendation:** take; three entries the encoder half has, and an |
| 2703 | +interrupt stub can't be written without them. |
| 2704 | + |
| 2705 | +**2. When an instruction joins, and the SHA and shuffle ones now.** |
| 2706 | +The rule, in `doc/compiler.md` beside the assembler: an instruction |
| 2707 | +joins when a program writes it in `db`, it is a family's member the |
| 2708 | +tables already hold (a code in `PackedOps`, an entry in `Plain`), and |
| 2709 | +its bytes are checked against GNU `as` in `test/run/`, as |
| 2710 | +`AsmKernel.raz` does. Anything else stays `db`, which is the permanent |
| 2711 | +answer for an instruction no program uses twice. By that rule, now: |
| 2712 | +- `paddd`, `punpcklqdq`, `punpckhqdq` into `PackedOps` (66 0F FE, 6C, |
| 2713 | + 6D); |
| 2714 | +- `pshufb` (66 0F 38 00) and `palignr` (66 0F 3A 0F, with a byte), |
| 2715 | + two more forms, three-byte opcodes; |
| 2716 | +- `sha256rnds2` (0F 38 CB, `xmm0` implied), `sha256msg1` (0F 38 CC), |
| 2717 | + `sha256msg2` (0F 38 CD). |
| 2718 | + |
| 2719 | +Sauce's SHA-NI hash is 123 `db` lines assembled by GNU `as`, nothing |
| 2720 | +checking a byte against its mnemonic; with these it is read as written. |
| 2721 | +AES-NI, `pclmulqdq`, AVX and the rest wait for a program. (`movd` and |
| 2722 | +`movq`, `pxor`, `pshufd`, `movdqu`, `movdqa`, `pmovmskb` are there |
| 2723 | +already.) |
| 2724 | + |
| 2725 | +**Recommendation:** take; a rule stops the list growing by wish, and |
| 2726 | +eight instructions turn sauce's 123 unchecked lines into checked ones. |
| 2727 | + |
| 2728 | +**3. `raz -S`'s listing, stated.** raz(1) gives the listing's form, so |
| 2729 | +a tool may read it: |
| 2730 | +- a blank line, then a procedure's name as `Module.name:`; |
| 2731 | +- a source line: its number right-aligned in 6 columns, two spaces, |
| 2732 | + the line's text; |
| 2733 | +- an instruction: its offset in the procedure right-aligned in 14 |
| 2734 | + columns, two spaces, the instruction as the assembler would read it, |
| 2735 | + a jump within the procedure giving its target as an offset. |
| 2736 | + |
| 2737 | +Only the main module's live procedures, in the order they were made; |
| 2738 | +nothing is disassembled. A change to the form is then a change to the |
| 2739 | +manual, and rcrypto's constant-time guard (`tools/branches.sh`), which |
| 2740 | +counts conditional jumps by reading these three kinds of line, breaks |
| 2741 | +loudly instead of silently. A test in raz holds the form against a |
| 2742 | +small program's listing. |
| 2743 | + |
| 2744 | +**Recommendation:** take; it is a paragraph of raz(1) and one test, |
| 2745 | +for a form that already doesn't change. |
| 2746 | + |
| 2747 | +## `Doc` for a library's pages |
| 2748 | + |
| 2749 | +**Status.** Proposed 2026-10-22, collated from RAZ-GAPS.md. |
| 2750 | + |
| 2751 | +`tools/Doc.raz` writes raz-lib(3) from `lib/`, and other libraries |
| 2752 | +have started to use it for their own pages. Two changes let them. |
| 2753 | + |
| 2754 | +**1. A comment that heads a group of constants.** A comment just |
| 2755 | +before `const`, `type` or `var`, on lines of its own, is the group's: |
| 2756 | +`Doc` writes it once, before the group's declarations, as it writes a |
| 2757 | +module's own comment, and each declaration keeps the comment just |
| 2758 | +before it as now. Today `section` reads past the keyword and drops it |
| 2759 | +(checked: each constant then shows alone), so mosaico's `Mxlib` has a |
| 2760 | +comment line for each of its 237 constants where one before each group |
| 2761 | +would halve the file. In mdoc the group's comment is filled text before |
| 2762 | +the literal display; in plain text, the comment as written. |
| 2763 | + |
| 2764 | +**Recommendation:** take; a few lines in `section` keep a comment the |
| 2765 | +standards already ask for. |
| 2766 | + |
| 2767 | +**2. `Doc man` writes the modules, not the page.** Today it writes |
| 2768 | +raz-lib(3)'s `.Dd`, `.Dt`, NAME, DESCRIPTION and SEE ALSO, fixed in the |
| 2769 | +tool, and a `Date` constant in `Doc.raz` dated by hand. The change: |
| 2770 | +`Doc man Module.raz ...` writes only what is now between `.Sh MODULES` |
| 2771 | +and `.Sh SEE ALSO`; raz's `Makefile` puts the head and tail around it |
| 2772 | +from `doc/raz-lib.head` and `doc/raz-lib.tail` (or one file with a |
| 2773 | +marker line), and the date lives with the page, not the tool. rcrypto's |
| 2774 | +`tools/man3.sh`, which cuts Doc's page between the two `.Sh` lines and |
| 2775 | +sets its own around it, then just wraps it, as raz does. Title, name |
| 2776 | +and description from the command line were the other way; three |
| 2777 | +options to replace two small files is the larger. |
| 2778 | + |
| 2779 | +**Recommendation:** take; it makes `Doc man` serve any library, and |
| 2780 | +`Doc.raz` loses its fixed text and its date. |
| 2781 | + |
| 2782 | +## Left out, to confirm |
| 2783 | + |
| 2784 | +What the collation of 2026-10-22 recommends leaving out, each with its |
| 2785 | +reason. The owner confirms or moves an item into a proposal; what is |
| 2786 | +confirmed is marked "Not planned" in `~/r/RAZ-GAPS.md`. |
| 2787 | + |
| 2788 | +### The language |
| 2789 | + |
| 2790 | + |
| 2791 | +- Several values are assigned at once only from a call — two statements say it; `a, b := b, a` would need a rule that every right side is read before any is stored. |
| 2792 | +- No conditional compilation — a constant module chosen by `-I` is the Wirth idiom, and `if Fake then` on a constant already reads as one program. |
| 2793 | +- Records don't compare with `=` — padding, reals (`-0.0`, NaN) and slices make a byte compare wrong; a `same` procedure says what equal means. |
| 2794 | +- No type of its own for an array — a one-field record keeps two hashes apart, as it keeps generic arrays (owner's idiom). |
| 2795 | +- No exporting a record's fields as a whole — each `*` is the reader's mark of what is public; `Mxlib` is a C mirror, made by a program. |
| 2796 | +- An exported array can't be read as a slice outside its module — a slice can be written through; "A slice that can't be written: `[]const T`" in PROPOSALS.md would answer it. |
| 2797 | +- An exported variable can't be assigned from outside — Oberon's read-only export; a setter shows who writes. |
| 2798 | +- A generic instance isn't reachable through the module that imported it — no bug: an import's name is never exported (3); export a type of the instance, or import it again. |
| 2799 | +- `I32` doesn't widen to `INT` — `INT` may be 16 bits (5.1), so the widening would not hold everywhere. |
| 2800 | +- Common words are reserved — settled. |
| 2801 | +- Text built at run time needs a `Buf` — with no collector a `+` of texts has no owner for its result; `Fmt.write` into a `Buf` is it. |
| 2802 | +- Every string a record keeps is freed by hand — no collector; an `Arena` per record frees all of them at once. |
| 2803 | +- Nothing in the report says anything of time — this is about constant-time code, not clocks (rzone doesn't answer it); a sentence would bind every later optimiser, and rcrypto isn't to be depended on. |
| 2804 | +- An `ERROR` carries no text from the other end — an `ERROR` is an identity as big as an address; text from a peer belongs in a result field. |
| 2805 | +- A module's test drags its imports into every user — costs compile time and a few bytes; a comment `(* for the test *)` on the import tells the reader. |
| 2806 | + |
| 2807 | +### Bits and bytes |
| 2808 | + |
| 2809 | + |
| 2810 | +- **`Buf` gives memory back unwiped.** — a program with secrets sizes |
| 2811 | + its `Buf` with `Buf.room` and calls `Tls.wipe(Buf.bytes(b))` before |
| 2812 | + `Buf.done`, as roauth does; a wipe in the library would duplicate |
| 2813 | + rnet's `Tls` backends. |
| 2814 | +- **No hash but FNV, and no wipe the compiler can't drop.** — hashing |
| 2815 | + and wiping go through rnet's `Tls` backends (`Tls.sha256`, |
| 2816 | + `Tls.wipe`); `Ws`'s SHA-1 and the two 8-line wipes in `Smtp` and |
| 2817 | + `Imapnet` move to `Tls` in rnet, and raz gains nothing. |
| 2818 | + |
| 2819 | +### Sys and Files |
| 2820 | + |
| 2821 | + |
| 2822 | +- No reserving address space — `mmap` of the most it will hold, then |
| 2823 | + `protect`, serves raudio; `MAP_NORESERVE` alone is not worth a |
| 2824 | + procedure. |
| 2825 | +- `Sys.openDir` gives no order — sorting the names is a few lines with |
| 2826 | + `Sort`, in the one program. |
| 2827 | +- No glob — one program (robbie), and which wildcards it takes is that |
| 2828 | + program's choice; a `*` over `openDir` is about 40 lines. |
| 2829 | +- A signal noted just before a `wait` doesn't break it — already |
| 2830 | + answered: `catch` SIGCHLD with the others and wait in `ready` on |
| 2831 | + catch's fd (child, signal or deadline at once), then `wait(pid, |
| 2832 | + false)`; `ignore(sig, false)` gives a caught signal its default back. |
| 2833 | + Worth a paragraph in the library volume, not a procedure. |
| 2834 | +- No word from the kernel when a file changes — inotify is Linux's, |
| 2835 | + with no match in the C backend's other systems or Moss; a 300 ms |
| 2836 | + look serves. |
| 2837 | +- No sleep a signal breaks into — `ready(-1, ms)` is that sleep for |
| 2838 | + `handle`, and `ready` on catch's fd for `catch`. |
| 2839 | +- No sockets but streams and datagrams to addresses — netlink and HCI |
| 2840 | + are Linux's, for one program. |
| 2841 | +- No user's name — the password database with NSS needs the C |
| 2842 | + library, which mosaico links anyway. |
| 2843 | +- `Sys.rawMode` doesn't flush typed-ahead input — keys typed ahead are |
| 2844 | + usually meant for the program; flushing would lose them. |
| 2845 | +- No positional read (`pread`, `fadvise`) — `seek` then `read` serves |
| 2846 | + the one program; `fadvise` is a hint, fine as a `SYSCALL`. |
| 2847 | +- No `madvise` in `Sys` — `munmap` then `mmap` gives pages back. |
| 2848 | + |
| 2849 | +### Numbers, strings, memory and Opt |
| 2850 | + |
| 2851 | + |
| 2852 | +- No fixed-capacity string — one program, a record of a length and an array, three lines. |
| 2853 | +- `Math.toReal` refuses `.5` and `5.` — it reads reals as the language writes them, and arkusz's 3-line `withZeros` serves its one user. |
| 2854 | +- `Math.toReal` is slow far from 10^0 — a fast path (Eisel and Lemire) is 60 lines and a table for one program's benchmark. |
| 2855 | +- `Math.pow` is not correctly rounded, and `Math.exp(y * Math.ln(x))` is worse — within an ulp as the header promises; correct rounding costs far more than one bit is worth. |
| 2856 | +- `Opt` has no GNU reordering, and does not say a `--` ended the options — options ending at the first operand is `Opt`'s stated rule, so that a command's own options pass through. |
| 2857 | +- `Opt` carries no completion words — completion is concha's, one program, and the table would grow for every user. |
| 2858 | +- A zero `Buf` or `Vec` isn't usable — deliberate: the core assumes no heap, and `init` says which allocator. |
| 2859 | +- Joining texts into a kept `[]U8` costs a `Buf` and a copy — `Str.join` then `Str.copy` is two calls, for one program. |
| 2860 | +- Case is ASCII only — Unicode case maps are large tables for one program; rrem has them. |
| 2861 | +- `Vec` gives no pointer to an element already in it — `Nodes.all(v)[k].next := m` already sets a field in place. |
| 2862 | +- No lenient base64 reader in `Str` — mail's junk is rmime's to handle; its 30 lines serve the one reader that meets it. |
| 2863 | +- `Check.int` takes `I64` — an `I32` widening to `I64` is the language's question, and one call site converts. |
| 2864 | +- `Rand` has no shuffle — `Rand` isn't generic, and Fisher and Yates over `below` is four lines. |
| 2865 | +- `Fmt.real(x, n)` rounds the binary value, not the decimal text — the Pascal double rounding is left; the round-trip need is met by `Fmt.short` above. |
| 2866 | + |
| 2867 | +### Freestanding programs and tools |
| 2868 | + |
| 2869 | + |
| 2870 | +- `Doc` fills a list — rcrypto's paragraphs read as well, and a line |
| 2871 | + indented further already means code, which a list's continuation |
| 2872 | + would muddle. |