From 1328b81779afcb821adfc3be12e5a88d1eb240d7 Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Fri, 16 Oct 2026 20:27:03 +0000 Subject: [PATCH] site: v0.18.1 The download, the report's and the library's PDFs and spec page with Buf.cut, Out.lines, Thread.signal and Opt's four. --- diff --git a/site/public/_redirects b/site/public/_redirects index c03379e..318c1d7 100644 --- a/site/public/_redirects +++ b/site/public/_redirects @@ -1 +1 @@ -/download/latest /download/raz-0.18.0-linux-x86_64.tar.gz 302 +/download/latest /download/raz-0.18.1-linux-x86_64.tar.gz 302 diff --git a/site/public/advanced/static.html b/site/public/advanced/static.html index 78c6483..92b1d11 100644 --- a/site/public/advanced/static.html +++ b/site/public/advanced/static.html @@ -65,7 +65,7 @@ $ ldd Bare not a dynamic executable $ ls -l Bare | awk '{print $5, "bytes"}' -26304 bytes +26296 bytes

It is statically linked: no interpreter, no shared libraries, no libc. ldd says so.

What it does when it runs

strace lists every system call a program makes. This is the whole of it:

@@ -134,7 +134,7 @@
$ raz Lean.raz
 $ raz Heavy.raz
 $ ls -l Lean Heavy | awk '{print $9, $5}'
-Heavy 28480
+Heavy 28472
 Lean 28464

The sizes differ by a few bytes, not by the hundreds of kilobytes that the table and the procedure would take: they are not in the executable at all. You can link in a library module without worrying what else it offers.

Stripping

diff --git a/site/public/download/raz-0.18.1-linux-x86_64.tar.gz b/site/public/download/raz-0.18.1-linux-x86_64.tar.gz new file mode 100644 index 0000000..9e28a36 Binary files /dev/null and b/site/public/download/raz-0.18.1-linux-x86_64.tar.gz differ diff --git a/site/public/download/raz-0.18.1-linux-x86_64.tar.gz.sha256 b/site/public/download/raz-0.18.1-linux-x86_64.tar.gz.sha256 new file mode 100644 index 0000000..761bf58 --- /dev/null +++ b/site/public/download/raz-0.18.1-linux-x86_64.tar.gz.sha256 @@ -0,0 +1 @@ +95184eacaa25bec1cdcd3e992c6ddc76c0a6fa95c5c5b50e48dc1b402ed65214 raz-0.18.1-linux-x86_64.tar.gz diff --git a/site/public/index.html b/site/public/index.html index f5c5971..9d9f48e 100644 --- a/site/public/index.html +++ b/site/public/index.html @@ -113,24 +113,24 @@ the library.

Download

-

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

raz 0.18.1 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.18.0 - SHA-256 + Download raz 0.18.1 + SHA-256
-
$ 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
+
$ tar xzf raz-0.18.1-linux-x86_64.tar.gz
+$ ln -s $PWD/raz-0.18.1-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.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 +and download/raz-0.18.1-linux-x86_64.tar.gz to this one, for +good. Earlier releases: 0.18.0, 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 d05f2adbfddd52eabbf10db275fa69390102f46e40825ae94adaeade219799aa

+

SHA-256 95184eacaa25bec1cdcd3e992c6ddc76c0a6fa95c5c5b50e48dc1b402ed65214

raz is under the ISC license.
diff --git a/site/public/raz-lib.pdf b/site/public/raz-lib.pdf index a9ffa50..83f3e82 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 c7eeddc..4fbee51 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 517a8c5..2d80e1f 100644 --- a/site/public/spec.html +++ b/site/public/spec.html @@ -886,7 +886,7 @@ Thread -threads, spawn and join, and Mutex, in any program; in one that uses C, made by C’s pthread_create +threads, spawn, join and signal, and Mutex, in any program; in one that uses C, made by C’s pthread_create Mem @@ -995,17 +995,20 @@ Mutex* = record ... end; (* zero is free *) proc spawn*(p: proc(arg: ^U8); arg: ^U8): (^Thread, ERROR); (* p(arg) in a new thread *) proc join*(t: ^Thread); (* waits for t to end, then frees its stack *) +proc signal*(t: ^Thread; sig: INT): INT; (* sig sent to t alone: 0, or minus an errno *) proc lock*(m: ^Mutex); proc unlock*(m: ^Mutex);

A Lock is for short sections: a thread that finds it taken tries again, giving up the processor now and then. A Mutex sleeps. Each of Thread’s threads runs on a stack of its own, with a page below it that can’t be touched, so that running off the stack stops the program with a message, as in the main thread. In a program that uses C, Thread makes its threads with C’s pthread_create, so that C’s library knows of them; in one that doesn’t, with the system’s own calls. The program is the same either way.

+

Sys.kill signals a program, and the system gives the signal to any of its threads; signal gives it to t alone, until t is joined, and is -3 (ESRCH) once t has ended. With Sys.handle(sig), a call t waits in, a read or a ready, fails with -4, so that one thread can break into another’s wait, as ^C breaks into the main thread’s. A signal sent before t begins its wait is only noted, so a program sends it again until t says it has stopped.

module Out;
 proc str*(s: []U8);
 proc char*(c: U8);
 proc ln*;                        (* a line feed *)
 proc int*(n: I64);               (* n in decimal *)
 proc hex*(n: U64; digits: INT);  (* n in hexadecimal, digits digits at least *)
-proc flush*;
-

Out and C’s stdio. Out keeps a buffer of Sys.outSize bytes, 4 KB on Linux. It writes it out when it is full, at each line feed when standard output is a terminal, at Out.flush, and when the program ends by Rt.exit. A lock keeps what each call writes together when threads write at once. C’s stdio keeps a buffer of its own for the same standard output. A program that writes with both flushes one before writing with the other, or the text comes out of order:

+proc flush*; +proc lines*(on: BOOL); (* written at each line feed, or only when full *) +

Out and C’s stdio. Out keeps a buffer of Sys.outSize bytes, 4 KB on Linux. It writes it out when it is full, at each line feed when standard output is a terminal, at Out.flush, and when the program ends by Rt.exit. lines(true) has it written at each line feed whatever standard output is, as a filter of a stream that comes slowly wants through a pipe, as grep’s --line-buffered; lines(false), only when full, at a terminal too. A lock keeps what each call writes together when threads write at once. C’s stdio keeps a buffer of its own for the same standard output. A program that writes with both flushes one before writing with the other, or the text comes out of order:

module Both;
 import Out, C;      (* C: printf, fflush and C's FILE *stdout *)
 
@@ -1241,6 +1244,7 @@
 proc str*(b: ^Buf; s: []U8);
 proc spare*(b: ^Buf; n: INT): []U8;   (* room for n more bytes, and those bytes, to fill *)
 proc bytes*(b: ^Buf): []U8;           (* what it holds, until it next grows *)
+proc cut*(b: ^Buf; n: INT);           (* only the first n bytes kept, its memory kept *)
 proc reset*(b: ^Buf);                 (* emptied, its memory kept *)
 proc done*(b: ^Buf);                  (* its memory given back *)
 
@@ -1316,7 +1320,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. 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);.

+

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;. cut takes back what was added, to a length it had: start := b^.len; ...; Buf.cut(b, start);; a length past len stops the program, as an index past the end does. 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
@@ -1363,6 +1367,7 @@
         letter*: U8;    (* the option just read *)
         value*: []U8;   (* its value; "" for a flag *)
         long*: BOOL;    (* it was written by its long name *)
+        spelt*: []U8;   (* as it was written, no dashes: "b" or "bar"; to read only *)
         ...
     end;
 proc init*(p: ^Parser; name: []U8; table: []Row);  (* the arguments from 1 on, by table *)
@@ -1371,9 +1376,10 @@
 proc at*(p: ^Parser): INT;                        (* the argument operand would give next *)
 proc scope*(p: ^Parser; name: []U8);              (* subcommand name's options, from the word after it *)
 proc number*(p: ^Parser; lo, hi: I64): I64;       (* the value just read, a number from lo to hi *)
+proc refuse*(p: ^Parser; wants: []U8);            (* the value just read refused, as number refuses one *)
 proc fail*(p: ^Parser; text: []U8);               (* the program's own mistake *)

Opt reads a command line by the rules of the C library’s getopt, with GNU’s long options, so that a program’s options behave as every other Unix program’s. The program describes itself once, in a table of Rows: its synopsis lines, its subcommands and its options. The help and the messages for mistakes are made from the table, so they can’t drift from it; the program’s test of p.letter is the only other place an option appears. The parser is a record the program owns, and the table a slice it keeps as long as the parser: a literal written in the call to init lives as long as the procedure that makes it.

-

A row’s scope is "" for the program itself, or a subcommand’s name: "start", or "remote.add" for a subcommand of remote. An option has a letter, a long name, or both. One with a long name only has a key of its own below '!' for a letter, so that the program can tell it from the others. With a value, the name the help and the messages give it, the option takes a value; with "" it is a flag.

+

A row’s scope is "" for the program itself, or a subcommand’s name: "start", or "remote.add" for a subcommand of remote. An option has a letter, a long name, or both. One with a long name only has a key of its own below '!' for a letter, so that the program can tell it from the others. With a value, the name the help and the messages give it, the option takes a value; with "" it is a flag. A value written in brackets, "[when]", may be left out, and is "" then: it is given only in the option’s own word, --color=always or -calways, never as the next, as getopt’s :: has it, and the help shows it as --color[=when].

const wait = 1;     (* the key of --wait, which has no letter *)
 ...
 Opt.init(ADR(p), "keep", [
@@ -1410,12 +1416,12 @@
 
   -b, --bar label   show the job in the bar as label
   -h, --help        print this and exit
-

A scope with several synopsis lines has the others indented under the first; one with none, usage: and its words, as usage: keep start.

+

A scope with several synopsis lines has the others indented under the first; one with none, usage: and its words, as usage: keep start. A scope may give -h to an option of its own, as grep’s “no file names”; help there is --help alone, and its row in the help has no letter.

A mistake on the command line is a sentence on standard error, the program’s name first, then the scope’s synopsis lines, as the help begins, and status 2:

keep: unknown option -x
 usage: keep start [-b label] name command [argument ...]
-

The sentences are unknown option -x (or --name, up to its =), -b needs a label, --follow takes no value and --wait wants a number from 1 to 600, not '0'. fail writes the program’s own mistakes the same way, but alone, so that the sentence can say where the help is: keep: no command; see keep -h.

-

A mistake in the table is the program’s, not its user’s. init checks the table before it reads a word, and ends the program with status 1: keep: option table, row 3: the option is in the scope already. The others are an option with neither a letter nor a long name, a long name with = in it, a letter -, and -h or --help in the table, since they are Opt’s.

+

The sentences are unknown option -x (or --name, up to its =), -b needs a label, --follow takes no value and --wait wants a number from 1 to 600, not '0'; for a number with no top, given the largest I64 for hi, --jobs wants a number from 1 up, not '0'. refuse refuses a value the program reads itself, as number refuses one, naming the option as the user wrote it, -b or --bar: Opt.refuse(ADR(p), "a label with no spaces") writes keep: -b wants a label with no spaces, not 'a b', and the synopsis lines. p.spelt is that spelling, for the program’s own sentences. fail writes the program’s own mistakes the same way, but alone, so that the sentence can say where the help is: keep: no command; see keep -h.

+

A mistake in the table is the program’s, not its user’s. init checks the table before it reads a word, and ends the program with status 1: keep: option table, row 3: the option is in the scope already. The others are an option with neither a letter nor a long name, a long name with = in it, a letter -, a value with one bracket but not the other, and --help in the table, since it is Opt’s.

Width says how many columns of a terminal text takes, for a program with a screen that wraps its lines and cuts them at the window’s edge.

module Width;
 proc width*(c: I32): INT;      (* the columns the character c takes: 0, 1 or 2 *)
diff --git a/site/public/tour/hello.html b/site/public/tour/hello.html
index ea8c881..f284c9e 100644
--- a/site/public/tour/hello.html
+++ b/site/public/tour/hello.html
@@ -70,7 +70,7 @@
 $ raz run Quiet.raz
 hello, again
 $ ls -l Quiet | awk '{print $5, "bytes"}'
-28480 bytes
+28472 bytes

The program is a static executable with no run time besides the code it uses, so it is a few kilobytes, and runs without any library installed.

What Out can write

Out is the library's buffered output. It writes strings, single characters, numbers in decimal or hexadecimal, and a line feed. A string is written as it is, with \n for a line feed, \t for a tab, \" and \\; or between backquotes, as a raw string with no escapes at all, which may run over lines (lesson 6).