raz / commit 9e477ea4

commit
9e477ea4b43affc085ccdb222b03b911a9dfcb83
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
b03190fd
Report draft 2026-10.11: the library in INT

Lengths, counts, fds, pids and statuses are INT (main and Rt.exit
too); a character is I32; file sizes and positions, times and numbers
read from text stay I64, since they may pass an INT on a small target.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

patch · log

1 file changed, +63 -55

doc/raz.md (history) modified +63 -55

@@ -1050,7 +1050,7 @@
10501050 ## 10. Programs
10511051
10521052 Any module may export a procedure `main`, declared `proc main*;` or
1053-`proc main*: I64;`. The program runs the bodies of all its modules
1053+`proc main*: INT;`. The program runs the bodies of all its modules
10541054 (section 3), then the main module's `main`, if it has one, and ends
10551055 with status 0, or with the status `main` returns, by calling
10561056 `Rt.exit`. The `main` of an imported module is an ordinary procedure,
@@ -1074,7 +1074,7 @@
10741074
10751075 ```
10761076 proc atExit*(p: proc): ERROR; (* Rt.Full if 32 are registered *)
1077-proc exit*(status: I64);
1077+proc exit*(status: INT);
10781078 ```
10791079
10801080 Only what can be reached from `main` and the module bodies goes into
@@ -1169,6 +1169,11 @@
11691169 | `Files` | an argument as a string, and a whole file read or written |
11701170 | `Opt` | a command line read through one table, by `getopt`'s rules with long options; its help and its mistakes |
11711171
1172+Lengths, counts, file descriptors, process ids and statuses are
1173+`INT`s, and a character is an `I32`. What may pass an `INT` on a small
1174+target is an `I64`: a file's size and position, a time in nanoseconds,
1175+and a number read from text.
1176+
11721177 ```
11731178 module Mem;
11741179 type
@@ -1200,7 +1205,7 @@
12001205 Info* = record
12011206 size*: I64; (* in bytes *)
12021207 mtime*: I64; (* when its contents last changed, in nanoseconds since 1970 *)
1203- mode*: I64; (* its permission bits, as chmod takes them: 1EDH is rwxr-xr-x *)
1208+ mode*: INT; (* its permission bits, as chmod takes them: 1EDH is rwxr-xr-x *)
12041209 dir*: BOOL; (* a directory *)
12051210 file*: BOOL; (* a regular file: not a directory, device, pipe or socket *)
12061211 symlink*: BOOL; (* the path itself is a symbolic link *)
@@ -1212,68 +1217,68 @@
12121217 env*: [][]U8; (* NAME=value, each added to this program's environment *)
12131218 onlyEnv*: BOOL; (* env is its whole environment *)
12141219 dir*: []U8; (* its working directory; "" for this program's *)
1215- fds*: [3]I64; (* its standard input, output and error; 0 for this program's own *)
1216- group*: I64; (* the process group it joins: 0 for this program's, -1 a new one it leads *)
1220+ fds*: [3]INT; (* its standard input, output and error; 0 for this program's own *)
1221+ group*: INT; (* the process group it joins: 0 for this program's, -1 a new one it leads *)
12171222 foreground*: BOOL; (* its group takes the terminal on standard input *)
1218- tty*: I64; (* a pseudo-terminal's fd, to start a session on; 0 for none *)
1223+ tty*: INT; (* a pseudo-terminal's fd, to start a session on; 0 for none *)
12191224 end;
12201225 Status* = (running, exited, killed, stopped);
12211226
1222-proc open*(path: []U8; how: Accesses): I64; (* its fd *)
1223-proc openRead*(path: []U8): I64; (* open(path, {reading}) *)
1224-proc create*(path: []U8): I64; (* open(path, {writing, creating, truncating}) *)
1225-proc seek*(fd, pos: I64; fromEnd: BOOL): I64; (* the new position *)
1227+proc open*(path: []U8; how: Accesses): INT; (* its fd *)
1228+proc openRead*(path: []U8): INT; (* open(path, {reading}) *)
1229+proc create*(path: []U8): INT; (* open(path, {writing, creating, truncating}) *)
1230+proc seek*(fd: INT; pos: I64; fromEnd: BOOL): I64; (* the new position *)
12261231
1227-proc rename*(old, new: []U8): I64; (* replaces what new names *)
1228-proc remove*(path: []U8): I64; (* a file, not a directory *)
1229-proc removeDir*(path: []U8): I64; (* an empty directory *)
1230-proc makeDir*(path: []U8): I64; (* readable by all, writable by its owner *)
1231-proc chmod*(path: []U8; mode: I64): I64;
1232-proc symlink*(target, path: []U8): I64; (* path made a link to target *)
1233-proc readLink*(path: []U8): ([]U8, I64); (* what the link names, good until the next call *)
1234-proc info*(path: []U8): (Info, I64); (* following a symbolic link *)
1232+proc rename*(old, new: []U8): INT; (* replaces what new names *)
1233+proc remove*(path: []U8): INT; (* a file, not a directory *)
1234+proc removeDir*(path: []U8): INT; (* an empty directory *)
1235+proc makeDir*(path: []U8): INT; (* readable by all, writable by its owner *)
1236+proc chmod*(path: []U8; mode: INT): INT;
1237+proc symlink*(target, path: []U8): INT; (* path made a link to target *)
1238+proc readLink*(path: []U8): ([]U8, INT); (* what the link names, good until the next call *)
1239+proc info*(path: []U8): (Info, INT); (* following a symbolic link *)
12351240
1236-proc openDir*(d: ^Dir; path: []U8): I64;
1241+proc openDir*(d: ^Dir; path: []U8): INT;
12371242 proc nextEntry*(d: ^Dir): ([]U8, BOOL); (* a name, good until the next call; false at the end *)
12381243 proc closeDir*(d: ^Dir);
12391244
1240-proc rawMode*(fd: I64): BOOL; (* the terminal on fd: no echo, no lines, no signals *)
1241-proc restoreMode*(fd: I64); (* as rawMode found it *)
1242-proc termSize*(fd: I64): (I64, I64); (* columns and rows; 80 and 24 if unknown *)
1243-proc ready*(fd: I64; ms: I64): BOOL; (* something to read within ms, or ever if ms < 0 *)
1244-proc readyOf*(fds: []I64; ms: I64): I64; (* the first of fds with something to read within ms, or -1 *)
1245+proc rawMode*(fd: INT): BOOL; (* the terminal on fd: no echo, no lines, no signals *)
1246+proc restoreMode*(fd: INT); (* as rawMode found it *)
1247+proc termSize*(fd: INT): (INT, INT); (* columns and rows; 80 and 24 if unknown *)
1248+proc ready*(fd: INT; ms: INT): BOOL; (* something to read within ms, or ever if ms < 0 *)
1249+proc readyOf*(fds: []INT; ms: INT): INT; (* the first of fds with something to read within ms, or -1 *)
12451250
12461251 proc env*(name: []U8): []U8; (* the environment variable's value; "" if unset *)
1247-proc workDir*: ([]U8, I64); (* the working directory, good until the next call *)
1248-proc setWorkDir*(path: []U8): I64;
1252+proc workDir*: ([]U8, INT); (* the working directory, good until the next call *)
1253+proc setWorkDir*(path: []U8): INT;
12491254
1250-proc pipe*: (I64, I64); (* the fd to read and the fd to write; or minus an errno and -1 *)
1251-proc openPty*: I64; (* a pseudo-terminal: the fd of its controlling side *)
1252-proc setTermSize*(fd, cols, rows: I64): I64; (* the size its programs are told of *)
1253-proc spawn*(p: Program): I64; (* a program started: its process id *)
1254-proc wait*(pid: I64; block: BOOL): (I64, Status, I64); (* which program, how, and its code *)
1255-proc kill*(pid, signal: I64): I64;
1256-proc pid*: I64; (* this program's process id *)
1257-proc setGroup*(pid, group: I64): I64; (* pid 0 is this program; group 0 a new one pid leads *)
1258-proc foreground*(fd, group: I64): I64; (* the terminal on fd gives its keys to group *)
1259-proc foregroundOf*(fd: I64): I64; (* the group the terminal on fd gives its keys to *)
1255+proc pipe*: (INT, INT); (* the fd to read and the fd to write; or minus an errno and -1 *)
1256+proc openPty*: INT; (* a pseudo-terminal: the fd of its controlling side *)
1257+proc setTermSize*(fd, cols, rows: INT): INT; (* the size its programs are told of *)
1258+proc spawn*(p: Program): INT; (* a program started: its process id *)
1259+proc wait*(pid: INT; block: BOOL): (INT, Status, INT); (* which program, how, and its code *)
1260+proc kill*(pid, signal: INT): INT;
1261+proc pid*: INT; (* this program's process id *)
1262+proc setGroup*(pid, group: INT): INT; (* pid 0 is this program; group 0 a new one pid leads *)
1263+proc foreground*(fd, group: INT): INT; (* the terminal on fd gives its keys to group *)
1264+proc foregroundOf*(fd: INT): INT; (* the group the terminal on fd gives its keys to *)
12601265
1261-proc catch*(sigs: []I64): I64; (* sigs caught: an fd to wait on *)
1262-proc caught*(fd: I64): I64; (* the next signal caught, or 0 if none is waiting *)
1263-proc ignore*(sig: I64; yes: BOOL): I64; (* sig ignored; or, if not yes, back to what it does at first *)
1266+proc catch*(sigs: []INT): INT; (* sigs caught: an fd to wait on *)
1267+proc caught*(fd: INT): INT; (* the next signal caught, or 0 if none is waiting *)
1268+proc ignore*(sig: INT; yes: BOOL): INT; (* sig ignored; or, if not yes, back to what it does at first *)
12641269
12651270 proc clock*: I64; (* nanoseconds, on a clock that only goes forward *)
12661271 proc now*: I64; (* nanoseconds since 1970-01-01, UTC *)
1267-proc sleep*(ms: I64);
1272+proc sleep*(ms: INT);
12681273 proc random*(b: []U8); (* b filled with random bytes *)
12691274
1270-proc connect*(path: []U8): I64; (* a stream socket, connected to the Unix socket at path: its fd *)
1271-proc connectTcp*(addr: []U8; port: I64): I64; (* addr an IPv4 or IPv6 address, as numbers *)
1272-proc connectUdp*(addr: []U8; port: I64): I64;
1273-proc listen*(path: []U8): I64; (* a Unix socket made at path, taking connections *)
1274-proc listenTcp*(addr: []U8; port: I64): I64;
1275-proc accept*(fd: I64): I64; (* the next connection, waiting for one *)
1276-proc send*(fd: I64; s: []U8): I64; (* write, to a socket: -32 (EPIPE), not a signal, if it is closed *)
1275+proc connect*(path: []U8): INT; (* a stream socket, connected to the Unix socket at path: its fd *)
1276+proc connectTcp*(addr: []U8; port: INT): INT; (* addr an IPv4 or IPv6 address, as numbers *)
1277+proc connectUdp*(addr: []U8; port: INT): INT;
1278+proc listen*(path: []U8): INT; (* a Unix socket made at path, taking connections *)
1279+proc listenTcp*(addr: []U8; port: INT): INT;
1280+proc accept*(fd: INT): INT; (* the next connection, waiting for one *)
1281+proc send*(fd: INT; s: []U8): INT; (* write, to a socket: -32 (EPIPE), not a signal, if it is closed *)
12771282 ```
12781283
12791284 `info` follows a symbolic link: `size`, `dir` and `file` are those of
@@ -1395,8 +1400,8 @@
13951400
13961401 ```
13971402 module Str;
1398-proc encode*(c: I64): ([4]U8, I64); (* c in UTF-8: its bytes, and how many *)
1399-proc decode*(s: []U8): (I64, I64); (* the character s starts with, and its length in bytes *)
1403+proc encode*(c: I32): ([4]U8, INT); (* c in UTF-8: its bytes, and how many *)
1404+proc decode*(s: []U8): (I32, INT); (* the character s starts with, and its length in bytes *)
14001405 proc toInt*(s: []U8): (I64, BOOL); (* s, in decimal; false if it isn't a number an I64 holds *)
14011406 proc le*(s: []U8): U64; (* s, at most 8 bytes, the first the lowest *)
14021407 proc be*(s: []U8): U64; (* s, at most 8 bytes, the first the highest *)
@@ -1405,7 +1410,7 @@
14051410
14061411 module Map(K, V; hash: proc(k: K): U64; eq: proc(a, b: K): BOOL);
14071412 proc remove*(m: ^Map; k: K): BOOL; (* false if k wasn't there *)
1408-proc next*(m: ^Map; i: I64): (I64, K, V); (* the entry after i *)
1413+proc next*(m: ^Map; i: INT): (INT, K, V); (* the entry after i *)
14091414
14101415 module Sort(T; less: proc(a, b: T): BOOL);
14111416 proc sort*(s: []T);
@@ -1421,7 +1426,7 @@
14211426 proc ln*(x: F64): F64;
14221427
14231428 module Fmt;
1424-type Arg* = variant ... real(r: F64; places: I64); end;
1429+type Arg* = variant ... real(r: F64; places: INT); end;
14251430 ```
14261431
14271432 `Str` reads and writes UTF-8. `encode` writes a character, of at most
@@ -1465,7 +1470,7 @@
14651470
14661471 ```
14671472 module Files;
1468-proc arg*(i: I64): []U8; (* argument i; 0 is the program's name *)
1473+proc arg*(i: INT): []U8; (* argument i; 0 is the program's name *)
14691474 proc read*(path: []U8; b: ^Buf.Buf): BOOL; (* the whole file added to b *)
14701475 proc write*(path, data: []U8): BOOL; (* the file made to hold data *)
14711476
@@ -1690,9 +1695,12 @@
16901695 `INT`, `UINT` and pointers (6.8). An integer constant past an
16911696 extern's parameters goes as an `INT` (9). Modules compile on their
16921697 own, into object files, and instances are named so that one type
1693- gives one name (section 10; appendix A). The library of section 11
1694- still says `I64` for its lengths, sizes, counts and descriptors;
1695- they become `INT` when it is revised for this version.
1698+ gives one name (section 10; appendix A). The library takes and gives
1699+ `INT` for lengths, counts, descriptors, process ids and statuses,
1700+ `main`'s and `Rt.exit`'s among them, and `I32` for a character;
1701+ `I64` stays for what may pass an `INT` on a small target: a file's
1702+ size and position, times, and numbers read from text (section
1703+ 11).
16961704
16971705 ## Appendix A. What an implementation chooses
16981706