From 1cd692402e08503a9f62ed3a8de0ec82d6f0dbd2 Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Fri, 16 Oct 2026 15:36:14 +0100 Subject: [PATCH] site: v0.18.0 --- diff --git a/site/public/_redirects b/site/public/_redirects index 74e7873..c03379e 100644 --- a/site/public/_redirects +++ b/site/public/_redirects @@ -1 +1 @@ -/download/latest /download/raz-0.17.2-linux-x86_64.tar.gz 302 +/download/latest /download/raz-0.18.0-linux-x86_64.tar.gz 302 diff --git a/site/public/download/raz-0.18.0-linux-x86_64.tar.gz b/site/public/download/raz-0.18.0-linux-x86_64.tar.gz new file mode 100644 index 0000000..4ee0a85 Binary files /dev/null and b/site/public/download/raz-0.18.0-linux-x86_64.tar.gz differ diff --git a/site/public/download/raz-0.18.0-linux-x86_64.tar.gz.sha256 b/site/public/download/raz-0.18.0-linux-x86_64.tar.gz.sha256 new file mode 100644 index 0000000..80e0431 --- /dev/null +++ b/site/public/download/raz-0.18.0-linux-x86_64.tar.gz.sha256 @@ -0,0 +1 @@ +d05f2adbfddd52eabbf10db275fa69390102f46e40825ae94adaeade219799aa raz-0.18.0-linux-x86_64.tar.gz diff --git a/site/public/index.html b/site/public/index.html index 45c1cfe..f5c5971 100644 --- a/site/public/index.html +++ b/site/public/index.html @@ -42,7 +42,7 @@
~10,700 lines of compiler ~500K lines compiled a second - 1 report, 30 pages + 1 report, 31 pages static executables, no run time to install
@@ -109,28 +109,28 @@

The language is defined by the report, which is short on purpose: whatever it doesn’t allow, raz doesn’t have. Its second volume describes the library. Both are on one page, and each is -a PDF: the language (30 pages) and +a PDF: the language (31 pages) and the library.

Download

-

raz 0.17.2 is a tarball for x86-64 Linux with the compiler, raz, +

raz 0.18.0 is a tarball for x86-64 Linux with the compiler, raz, its library, lib/, which it finds beside itself, the formatter and the documentation tool as sources in tools/, and the manual pages. It needs nothing else installed.

- Download raz 0.17.2 - SHA-256 + Download raz 0.18.0 + SHA-256
-
$ tar xzf raz-0.17.2-linux-x86_64.tar.gz
-$ ln -s $PWD/raz-0.17.2-linux-x86_64/raz ~/.local/bin/raz
+
$ tar xzf raz-0.18.0-linux-x86_64.tar.gz
+$ ln -s $PWD/raz-0.18.0-linux-x86_64/raz ~/.local/bin/raz
 $ raz run Hello.raz

The link works since raz finds lib/ beside its real path. The manual pages are in man/: man ./man/raz-tutorial.7. The address download/latest always leads to the newest release, -and download/raz-0.17.2-linux-x86_64.tar.gz to this one, for -good. Earlier releases: 0.17.1, 0.17.0, 0.16.0, 0.15.0, 0.14.0, 0.13.0, 0.12.0, 0.11.1, 0.11.0, 0.10.1, 0.10.0, 0.9.1, 0.9.0, 0.8.0, 0.7.1; each has its SHA-256 beside it, with +and download/raz-0.18.0-linux-x86_64.tar.gz to this one, for +good. Earlier releases: 0.17.2, 0.17.1, 0.17.0, 0.16.0, 0.15.0, 0.14.0, 0.13.0, 0.12.0, 0.11.1, 0.11.0, 0.10.1, 0.10.0, 0.9.1, 0.9.0, 0.8.0, 0.7.1; each has its SHA-256 beside it, with .sha256 added to its name.

-

SHA-256 ba019964915644ce6c0efe08258a08dcaf6ee20ce37a32ac2404a587c0b2c387

+

SHA-256 d05f2adbfddd52eabbf10db275fa69390102f46e40825ae94adaeade219799aa

raz is under the ISC license.
diff --git a/site/public/raz-lib.pdf b/site/public/raz-lib.pdf index 0bbf95a..a9ffa50 100644 Binary files a/site/public/raz-lib.pdf and b/site/public/raz-lib.pdf differ diff --git a/site/public/raz.pdf b/site/public/raz.pdf index 9d2dee1..c7eeddc 100644 Binary files a/site/public/raz.pdf and b/site/public/raz.pdf differ diff --git a/site/public/spec.html b/site/public/spec.html index 08d9666..517a8c5 100644 --- a/site/public/spec.html +++ b/site/public/spec.html @@ -38,7 +38,7 @@

raz is a small systems language, first made for x86-64 Linux. A raz program can lay a record over a device’s registers, read and write a device’s memory exactly as written, take part in lock-free algorithms, make system calls and call C libraries. It has no garbage collector and no hidden run time: what the program does is what its text says.

This is the first volume of the report: the language, what an implementation chooses, and the grammar. The second, doc/raz-lib.md, is the library, which sections 3 and 10 and appendix A name.

This report defines the language. It is short on purpose. Whatever it doesn’t allow, raz doesn’t have.

-

This is version 2026-10.31 of the report; section 11 says where each version’s changes are told. 2026-10.11 and 2026-10.12 are a thaw the owner chose, for a language anyone can build again. They break programs written for 2026-10.10 and before: for 2026-10.9, say, the report of compiler 0.5.0, the last release before them; and 2026-10.12 breaks code procedures written for 2026-10.11. 2026-10.20 is a third, for try (section 7.8); it breaks a program that has a name try. 2026-10.25 is a fourth, for strings: raw strings, which may run over lines and may be indented with the code around them (section 2), and match on a string (section 7.4); it breaks no program. 2026-10.26 is a fifth: an INT widens to an I64 wherever it goes to one, in an expression too (sections 5.10 and 6.1); and a view, v.(T), reads and writes the bytes of a variable as a T (section 6.9); it breaks no program. 2026-10.27 mends a defect: returning a slice of the procedure’s own frame is an error (section 7.3), which breaks only a program that read memory already gone. 2026-10.28 mends another: an array a call returns lives to the end of its statement, and a slice of it kept past that is undefined (sections 8 and 10). 2026-10.29 is a sixth thaw: an array constant typed []T takes its length from its literal (section 4); it breaks no program. 2026-10.30 mends a defect: [] used as a slice is the empty slice, which may be returned (sections 6.5 and 7.3); it breaks no program. 2026-10.31 is a seventh thaw: INT is at least 16 bits, and U8, I8 and I16 widen to it (sections 5.1, 5.10 and 6.1); an enumeration’s name may be written with its type, and must be where another declaration shares it (section 5.7); and continue (section 7.2), which breaks a program that has a name continue.

+

This is version 2026-10.32 of the report; section 11 says where each version’s changes are told. 2026-10.11 and 2026-10.12 are a thaw the owner chose, for a language anyone can build again. They break programs written for 2026-10.10 and before: for 2026-10.9, say, the report of compiler 0.5.0, the last release before them; and 2026-10.12 breaks code procedures written for 2026-10.11. 2026-10.20 is a third, for try (section 7.8); it breaks a program that has a name try. 2026-10.25 is a fourth, for strings: raw strings, which may run over lines and may be indented with the code around them (section 2), and match on a string (section 7.4); it breaks no program. 2026-10.26 is a fifth: an INT widens to an I64 wherever it goes to one, in an expression too (sections 5.10 and 6.1); and a view, v.(T), reads and writes the bytes of a variable as a T (section 6.9); it breaks no program. 2026-10.27 mends a defect: returning a slice of the procedure’s own frame is an error (section 7.3), which breaks only a program that read memory already gone. 2026-10.28 mends another: an array a call returns lives to the end of its statement, and a slice of it kept past that is undefined (sections 8 and 10). 2026-10.29 is a sixth thaw: an array constant typed []T takes its length from its literal (section 4); it breaks no program. 2026-10.30 mends a defect: [] used as a slice is the empty slice, which may be returned (sections 6.5 and 7.3); it breaks no program. 2026-10.31 is a seventh thaw: INT is at least 16 bits, and U8, I8 and I16 widen to it (sections 5.1, 5.10 and 6.1); an enumeration’s name may be written with its type, and must be where another declaration shares it (section 5.7); and continue (section 7.2), which breaks a program that has a name continue. 2026-10.32 is an eighth thaw: a constant typed []T may be [], the empty slice (section 4); it breaks no program.

The language is frozen, softly, from this version on: it changes only to mend a defect, and its library grows only by what breaks no program written for it. What anyone wishes it had waits on a list, for a later thaw.

1. A first look

module Hello;
@@ -139,16 +139,17 @@
     Line = Text + "\n";
 ...
 w := Text[4..7];    (* "cat" *)
-

A constant with a type is an ERROR (section 5.8), an array or a record, and the value of an array or record constant is a literal (section 6.5) of constants. Its elements and fields are integers, reals, BOOLs, enumerations, sets, ERRORs, procedures, nil, a string for a []U8, an array constant for a slice of its element type, and arrays and records of these; no variant and no other pointer:

+

A constant with a type is an ERROR (section 5.8), an array or a record, and the value of an array or record constant is a literal (section 6.5) of constants. Its elements and fields are integers, reals, BOOLs, enumerations, sets, ERRORs, procedures, nil, a string for a []U8, an array constant or the empty slice for a slice of its element type, and arrays and records of these; no variant and no other pointer:

const Primes: [5]I64 = [2, 3, 5, 7, 11];
 type Rule = record class: []U8; tag: INT; float: BOOL; end;
 const Rules: [2]Rule = [{class: "firefox", tag: 2}, {class: "mpv", float: true}];
 ...
 p := Primes[i];

It is used as a variable of that type is, but can’t be changed: an array constant can be indexed and sliced and its LEN is n, a record constant’s fields can be read, and either can be assigned, compared as its type allows, and passed. Its parts are constant as a string’s bytes are (section 5.10). A part of it isn’t a constant, even at a constant index.

-

An array constant may be typed []T, with no length: its length is then its literal’s, as a string constant’s is the string’s, and it is an array constant of that length, [n]T, in all else. Its literal has at least one element.

+

An array constant may be typed []T, with no length: its length is then its literal’s, as a string constant’s is the string’s, and it is an array constant of that length, [n]T, in all else. If its literal is [], it is no array but the empty slice, as a slice variable starts: a value of type []T, used as a slice is, and LEN of it is 0 but not a constant.

const Wide: [][2]I32 = [[1100H, 115FH], [2E80H, 303EH], [0AC00H, 0D7A3H]];
-    Count = LEN(Wide);    (* 3, a constant *)
+ Count = LEN(Wide); (* 3, a constant *) + Narrow: [][2]I32 = []; (* the empty slice *)

Variables of a module live as long as the program; variables of a procedure live as long as its call. Both start at zero: every byte of them is zero. So a number starts as 0 (0.0 for F32 and F64), a BOOL as false, a pointer, procedure or ERROR as nil, a slice as the empty slice (ptr is nil, len is 0), a variant as its first case with its fields zero, a set as the empty set, and an enumeration as its first name. No variable is ever read before it has a value.

5. Types

Type      = QualIdent
@@ -1044,6 +1045,7 @@
         symlink*: BOOL;  (* the path itself is a symbolic link *)
         ino*: U64;       (* its inode, which a rename keeps and a new file doesn't *)
         dev*: U64;       (* the file system it is on; with ino, it names the file *)
+        links*: U64;     (* how many names it has: 1 for a file no hard link shares *)
     end;
     Kind* = (unknown, isFile, isDir, isLink, isOther);   (* what a directory says a name in it is *)
     Dir* = record ... end;   (* an open directory; its fields are the target's *)
@@ -1174,7 +1176,7 @@
 proc mapFile*(fd, size: INT): ^U8; (* the first size bytes of fd, shared; munmap gives them back; or nil *)

info follows a symbolic link: size, dir and file are those of what it names, and symlink says the path was a link, so that a program walking a tree can choose not to follow one back up it. A link to nothing is -ENOENT, as a missing file is. file lets a walk open only what holds data: opening a pipe would wait for a program to write to it.

nextEntry gives every name in the directory except . and .., in no particular order. entryKind says what the name it gave last is, a file, a directory, a symbolic link (whatever it names) or something else, as the directory itself records it, so that a program walking a tree needn’t ask linkInfo of every name, a system call each; where the file system doesn’t record it, it is unknown, and linkInfo must be asked. rawMode turns off what the terminal does with keys before the program reads them (echo, line editing, signals, flow control), and NL to CR NL on output. A program that turns it on restores it before it ends: Rt.atExit is the place.

-

Files. open gives a file for what how asks: reading, writing or both; creating it if it is missing, readable by all and writable by its owner; with exclusive, failing with -17 (EEXIST) if it is there, as a program does that makes a lock or a file of its own; truncating it to nothing; appending, each write going to its end, however other programs write it too. openMode is open that gives a file it makes the bits mode, less those the umask takes away: 1EDH (755) for a program, 124H (444) for a file never to be written; open gives 1A4H (644). seek moves to pos from the start of the file, or from its end if fromEnd, where a negative pos reads back from the end; position says where the file is, without moving. truncate makes the file size bytes long, cutting it or adding zeros, and leaves the position where it was. sync returns once what was written to the file is on the disk, as a program needs before it says a file is saved; syncAll returns once everything written to the file system that holds the file is on the disk, at once rather than a file at a time, and may flush other file systems too. lock takes the file’s lock, which one open file holds at a time: another that asks for it waits if wait, and otherwise fails with -11 (EAGAIN). The lock goes when the file is closed or the program ends, however it ends, so it never goes stale as a file made with exclusive does. infoOf is info of an open file: its size is what it holds now, however it was written; linkInfo is info of a symbolic link itself, not what it names, so that symlink is true, dir and file false, and size the length of what it names, which need not be there. Info.mtime is what a program checks to see whether a file changed under it, and Info.ino whether it is still the same file, not one renamed over it; 0 on a target whose files have none. Info.dev is the file system the file is on: two files are one only if both dev and ino agree, which is how a program following links finds that one has led it back into a directory it is already in. Info.mode holds the nine bits of rwxrwxrwx, and chmod sets them, 1EDH (755) for a program, 1A4H (644) for data.

+

Files. open gives a file for what how asks: reading, writing or both; creating it if it is missing, readable by all and writable by its owner; with exclusive, failing with -17 (EEXIST) if it is there, as a program does that makes a lock or a file of its own; truncating it to nothing; appending, each write going to its end, however other programs write it too. openMode is open that gives a file it makes the bits mode, less those the umask takes away: 1EDH (755) for a program, 124H (444) for a file never to be written; open gives 1A4H (644). seek moves to pos from the start of the file, or from its end if fromEnd, where a negative pos reads back from the end; position says where the file is, without moving. truncate makes the file size bytes long, cutting it or adding zeros, and leaves the position where it was. sync returns once what was written to the file is on the disk, as a program needs before it says a file is saved; syncAll returns once everything written to the file system that holds the file is on the disk, at once rather than a file at a time, and may flush other file systems too. lock takes the file’s lock, which one open file holds at a time: another that asks for it waits if wait, and otherwise fails with -11 (EAGAIN). The lock goes when the file is closed or the program ends, however it ends, so it never goes stale as a file made with exclusive does. infoOf is info of an open file: its size is what it holds now, however it was written; linkInfo is info of a symbolic link itself, not what it names, so that symlink is true, dir and file false, and size the length of what it names, which need not be there. Info.mtime is what a program checks to see whether a file changed under it, and Info.ino whether it is still the same file, not one renamed over it; 0 on a target whose files have none. Info.dev is the file system the file is on: two files are one only if both dev and ino agree, which is how a program following links finds that one has led it back into a directory it is already in. Info.links is how many names the file has: more than 1 if a hard link shares it, so that writing to it writes to a file named elsewhere too; 0 on a target that doesn’t say. Info.mode holds the nine bits of rwxrwxrwx, and chmod sets them, 1EDH (755) for a program, 1A4H (644) for data.

Programs. openPty makes a pseudo-terminal, a terminal that a program, a terminal emulator, plays the screen and the keyboard of: what it writes to the fd is typed, and what the programs on the terminal write it reads.

spawn starts the program at p.path, with p.args as its arguments, the first being its name. A p.path without a / is looked for as a shell looks for a command, and as C’s execvp does: in each directory of this program’s PATH in turn, an empty one being the working directory, or of /bin:/usr/bin if PATH is unset or empty; the first that runs is the program. Its environment is this program’s with each NAME=value of p.env added or put in place of the old value, or, if p.onlyEnv, p.env alone. It starts in p.dir. Its standard input, output and error are p.fds; a 0 gives it this program’s own, so {path: "ls", args: ["ls"]} runs ls as a shell runs it, with every other field zero. It gets no other open file but those of p.more, each at its own number, as a shell passes 3<file on, every signal does what it does at first, and none is blocked. If p.tty is a pseudo-terminal’s fd, the program starts a session on that terminal: it is its controlling terminal, and its standard input, output and error, and p.fds and p.group are not used.

p.group puts the program in a process group, the programs that a shell’s job is made of: -1 makes it the first of a new group, whose number is its process id, and the other programs of the job join that number. The terminal gives its keys, and the signals of Ctrl-C and Ctrl-Z, to one group, the one in its foreground: p.foreground puts the program’s group there before it starts, and foreground puts any group there, as a shell does to take the terminal back. setGroup moves a program to a group, as the shell does for each program it starts, for whichever of the two runs first; a shell runs in a group of its own, setGroup(0, 0).

@@ -1280,6 +1282,7 @@ proc init*(v: ^Vec; a: ^Mem.Allocator); proc room*(v: ^Vec; n: INT): BOOL; (* room for n more; false if the allocator has none *) proc push*(v: ^Vec; x: T); (* x added at the end *) +proc pop*(v: ^Vec): (T, BOOL); (* the last element, taken off; false if the array is empty *) proc add*(v: ^Vec): ^T; (* a new element at the end, zero, to fill in place *) proc tryPush*(v: ^Vec; x: T): BOOL; (* push; false, and v as it was, if there is no room *) proc tryAdd*(v: ^Vec): (^T, BOOL); (* add; nil and false, and v as it was, if there is no room *) @@ -1313,7 +1316,7 @@ proc fromBits*(u: U64): F64; (* the F64 whose bits are u *) proc mul*(a, b: U64): (U64, U64); (* a times b: the low 64 bits of the product, and the high *) proc toReal*(s: []U8): (F64, BOOL); (* s as a real, the F64 nearest it; false if it isn't one *) -

A Buf, a List, a Map and a Vec take their memory from the allocator init gives them. Buf.add, str and spare stop the program, as a failed check does, if the allocator has no room; room asks first. A program reads into a Buf through spare, then adds what it read to len: s := Buf.spare(b, 4096); n := Sys.read(fd, s); if n > 0 then INC(b^.len, n); end;. A Vec is Buf for any T: one block, which doubles when it is full, so push costs the same on average however long it grows. all gives the elements as a slice, indexed and checked as any is, and v.len is their number; the slice, and what add gives, are good until the array next grows. push, add and resize stop the program, as Buf.add does, if the allocator has no room; room asks first: import Lines := Vec([]U8);. Fmt’s format takes the next argument at each {}; {{ and }} stand for { and }. A Map hashes and compares its keys with the procedures it is given: import Count := Map([]U8, INT, Str.hash, Str.eq);.

+

A Buf, a List, a Map and a Vec take their memory from the allocator init gives them. Buf.add, str and spare stop the program, as a failed check does, if the allocator has no room; room asks first. A program reads into a Buf through spare, then adds what it read to len: s := Buf.spare(b, 4096); n := Sys.read(fd, s); if n > 0 then INC(b^.len, n); end;. A Vec is Buf for any T: one block, which doubles when it is full, so push costs the same on average however long it grows. all gives the elements as a slice, indexed and checked as any is, and v.len is their number; the slice, and what add gives, are good until the array next grows. pop takes the last element off, keeping the memory. push, add and resize stop the program, as Buf.add does, if the allocator has no room; room asks first: import Lines := Vec([]U8);. Fmt’s format takes the next argument at each {}; {{ and }} stand for { and }. A Map hashes and compares its keys with the procedures it is given: import Count := Map([]U8, INT, Str.hash, Str.eq);.

Str reads and writes UTF-8. encode writes a character, of at most 10FFFFH, in one to four bytes; a number that isn’t one becomes FFFDH, the character that stands for a wrong one. decode reads the first character of s, and gives FFFDH and 1 for a byte that doesn’t start one rightly, and 0 and 0 for an empty s: a continuation, a byte followed by too few continuations, a surrogate, a character beyond 10FFFFH or one spelled in more bytes than it needs. decodeLast reads the last character in the same way, to walk a string backwards. valid says that decode finds no such byte in s, and chars counts the characters, each such byte one. next walks a string a character at a time, as decode reads them: from 0, it gives the character at i and where the one after it starts, and 0 and -1 when i is at the end, or past it:

c, i := Str.next(s, 0);
 while i >= 0 do