Skip to content

Zeno 0.8.0

Latest

Choose a tag to compare

@github-actions github-actions released this 20 Nov 12:26

Zeno 0.8.0 is a release for the language itself. A function can give
several values, let q, r = divide(7, 2). An enum and an interface can
leave a type open, enum Maybe[T] and interface Source[T], and a
type parameter can say what it asks of its type, [T is Ordered]. An
owned class that is Resource is put back on every way out of the
block that holds it, and with it a file can be read and written in
pieces, closed when its owner ends. A program can list and make
folders, an assert can say why it matters, and zeno test --build
runs a program's tests in the program that C or LLVM makes of it.

Most of what zeno run ran and a build with no collector refused is
now built too: raises in a function type, a function that is kept
and takes what it uses, a method used as a value, take in front of a
field or an item, a value with one owner in a generic, a dict that
owns its values, and a function inside a function. What is still
refused is in one table, with the reason for each.

It ends items 9 to 12 of
docs/missing.md,
the list of what Zeno lacks, and two of the tools of item 13. The other
tools of item 13 and all of item 14 are put off, and nothing of them
is in this release.

Everything new is asked for. Each feature begins with a word or a
flag that a program writes: -> with two types, [T] on an enum,
is Resource, files.read_from, --build, --pool. A program that
writes none of them is built into the same C, IR and bytecode as by
0.7.0, to the byte, and the runtime written into it is 0.7.0's:
tools/same.py compares the two releases, and a test holds the
runtime. Everything a program wrote for 0.7.0
means what it meant, and no name is taken that a program could have
used: Ordered and Resource are a program's own if it declares
them.

The engines were not timed for this release. Nothing of it was
compared with 0.7.0 by the clock or by a count of instructions. What
a program that uses nothing new runs is 0.7.0's code, as above, but
no figure says so.

Installing

Windows: download zeno-0.8.0-windows-setup.exe below and run it.
It is not signed, so Windows warns the first time: "More info", then
"Run anyway".

macOS and Linux:

curl -fsSL https://github.com/zeno-src/zeno-lang/releases/download/v0.8.0/install.sh | sh

Both put zeno on the PATH and offer to install a C compiler and git
if the machine has none.
docs/install.md
says what they do. The archives further down are for installing by
hand.

Homebrew, on macOS and Linux:

brew tap zeno-src/zeno-lang https://github.com/zeno-src/zeno-lang
brew install zeno-src/zeno-lang/zeno

With another package manager. There is a package for apt, pacman,
snap and flatpak, installed from its file:

sudo apt install ./zeno_0.8.0_amd64.deb                         # Debian, Ubuntu, Raspberry Pi OS
sudo pacman -U zeno-lang-bin-0.8.0-1-x86_64.pkg.tar.zst         # Arch
sudo snap install --classic --dangerous zeno_0.8.0_amd64.snap
flatpak install --user zeno-0.8.0-x86_64.flatpak

The .deb is also there for arm64, armhf (every Raspberry Pi with
a 32-bit system) and i386, the snap for arm64 and armhf, and the
flatpak for aarch64. apt installs a C compiler and git along with
Zeno if the machine has none.

raises in a function type

A function type can say what a function of that type raises, as the
function's own first line does: function(str) -> int raises ValueError. A call through such a value is checked as a call of the
function by its name, so its caller catches the error or says
raises itself. A function fits the type if except ValueError would
catch what it raises, and raises Error takes any. A firmware build
and a build with no collector used to refuse texts.map(parse) where
parse raises; they build it now, and print what zeno run prints.
A function that returns a raising function writes that type in
brackets, -> (function(int) -> int raises ValueError) raises Missing, since raises after a result has always belonged to the
function it ends. See
docs/raises-in-types.md
and chapter 56 of the decisions. After raises, or none needs the
brackets too, since function() raises ValueError or none could be read
as raising ValueError or nothing.

A function that is kept takes what it uses

A function written where a value goes, which is returned, put in a
variable or a field, or given to a parameter that says take, now
takes each value with one owner that it uses, as let b = a would,
and frees them when it is freed. A build with no collector refused
such a function before, so compose(f, g) could not be written there;
it builds now. A function only passed along, to map or a parameter
that looks, looks as before. It cannot take a var, in any build:
the var could be given a new value after it was taken, and the
message says to declare it with let. With no collector, a function called
straight from the call that made it, as in make(2)("5"), is freed at
the end of its line; 0.7.0 left it. See
docs/kept-functions.md.

A method used as a value

let m = counter.bump builds with both compilers, in every build. It
is the function that calls the method: passed along, it looks at
counter, and kept, it takes it where counter has one owner. It is
bound to the object counter holds on that line, as zeno run binds
it. 0.7.0 ran it with zeno run and refused it in every build. See
docs/method-values.md.

take in front of a field or an item

let task = take slot.task gives what the field holds and leaves
none there; take tasks[i] does the same for an item of a list. The
place must be one that may hold none. It means the same in every
build, and with one owner it is how an object hands on what it holds,
which it could not do before. take was a reserved word already, so
nothing that built before changes. See
docs/take.md.

A value with one owner in a generic

With no collector, a list or an object can now fill a type parameter:
Stack[Frame], Box([1, 2]) and same(frame) build, and the copy is
checked as a class or function written by hand for that type would be.
take T says that a generic keeps what it is given, and is right for
a number too. See
docs/generic-owned.md.

A dict that owns its values

With no collector, a dict can now hold lists and objects:
dict[str, Channel] builds, and the dict owns its values as a list
owns its items. d[key] looks, a store over a key frees the value
that was there, pop(key) hands it over, and clear and the end of
the dict free every value. get(key, instead) and values() are
refused there, with what to write instead. See
docs/dict-owned.md.

A list of numbers that may be none, with no collector

With no collector, list[int or none], list[float or none] and the
rest now build. The list owns a small block of the pool for each
number, as it owns its copy of each text, and none takes none: a
store frees the old block, pop and take free the one they read
out, and clear and the end of the list free every one. Each number
costs a block of the pool, so on a small board a plain list with a
number that stands for "nothing", or an enum with a Missing case, is
still the cheaper list. See
docs/none-list.md.

The size of the pool on the command line

zeno build --no-collector --pool 4096 and --text-room 2048 set the
size of the pool and of the text room, which until now took a flag
for the C compiler by hand. They go with --board and --llvm, and
are refused, with the reason, where there is no fixed pool. With
--memory and no collector, a block that is given back is filled,
and a write to it before it is handed out again stops the program
with a message: the check the heap checkers of C cannot make inside
the pool. Without --memory the C is what it was. See
docs/pool-size.md.

A function inside a function, and a default that is worked out

zeno build now takes a function with a name written inside a
function, and a default that is more than a literal, through C and
LLVM, with or without a collector. One that uses nothing of the
function around it becomes a function of the file, so it can be called
above its line; one that does is made once, after the last thing it
uses. A default is worked out at each call that leaves its argument
out, reading the parameters before it and the file's names. See
docs/inner-functions.md.

What a build still refuses, in one place

Every refusal that the pages of a build named was tried again. What a
build with no collector still refuses is all by design, and is one
table in
docs/no-collector.md;
what every build still refuses is one table in
docs/compiler.md,
each row with its reason. A test holds the compilers to both tables.
Four messages say more than they did: print([]), a variable that
only holds none, a method that comes with Zeno used as a value, and
a class or an enum inside a function through LLVM.

What zeno run runs and a build refused

range(5) used as a value, as in 3 in range(5) or let r = range(5), now builds, with both compilers and with no collector. So do
in on a list whose items may be none through C, [3] in rows with
no collector, a list or an object made in the default of a parameter
that only looks, a default that holds lists or bytes, a list of two
functions of one type, and [none] or [] beside lists that say what
they hold. A new tool, tools/refused.py, builds several hundred
small programs, one operation on one type, every way, and fails on any
refusal that the tables of docs/no-collector.md and
docs/compiler.md do not list; those tables have five more rows, each
with its reason. Two messages say more than they did: a u64 that may
be none, and a dict of objects of an owned class where there is a
collector.

Several values from one function

function divide(a: int, b: int) -> (int, int) gives two values with
return a // b, a % b, and let q, r = divide(7, 2) receives them;
low, high = high, low swaps. Every value is received (_ drops
one), and several values are never one value: kept, listed, printed
or passed as one, they are refused with a message that says to
receive each or declare a class. It works in zeno run, the VM, every
build, with or without a collector, and every target. See
docs/several-values.md
and chapter 57 of the decisions.

Generic enums

An enum can have type parameters, as a class can: enum Maybe[T] { Nothing; Just(value: T) } and enum Result[T, E] { Ok(value: T); Failed(error: E) }. Just(3) is a Maybe[int] by what it carries,
and Nothing takes its type from where it goes: a variable, a
parameter, a field, a list, a dict, what a function returns, the other
side of ==, or the other arguments of a generic. Where nothing says,
the message shows how to write it. A match on a copy is checked for
cases left out as any enum is. It works in every engine, every build
and every target; with no collector a Maybe[Frame] owns its frame.
0.7.0 refused enum Maybe[T]. See
docs/generics.md
and 58.1 of the decisions.

Bounds

A type parameter may say what it asks of its type: function largest[T is Ordered](items: list[T]) -> T, function total[S is Shape](shapes: list[S]) -> float, and the same on a class or an
enum. A type that lacks it is refused at the call, which names both:
"Task is not Shape, which total asks of S", where before the
mistake was found inside the generic. Ordered comes with Zeno: every
kind of number, a quantity and text, what < works on; a program's
own Ordered is its own. total takes a list[Circle], which
list[Shape] does not. A bound makes no code. See
docs/generics.md
and 58.3 to 58.5 of the decisions.

Generic interfaces

An interface can have type parameters, as a class can: interface Source[T] { function next(self) -> T or none }. A class says which
copy it is, class Countdown is Source[int], and a generic class may
say class Repeat[T] is Source[T]. Source[int] and Source[str]
are two interfaces, each with every rule of an interface, and either
can be a bound or an owned interface. It works in every engine,
every build and every target. 0.7.0 refused interface Source[T].
See
docs/interfaces.md
and 58.6 of the decisions.

What interfaces left out

Three things an interface could not do in 0.7.0, each asked for by
what a program writes:

  • A default on a parameter of an interface's function:
    function spin(self, speed: int = 1000, wait: ms = 5 ms). It is a
    plain value (a number, text, true, false, none, a quantity, or
    a case of an enum that carries nothing), and each class writes the
    same value, so a call through the interface and a call on the
    object mean the same. A class may still have a default of its own
    where the interface has none, as in 0.7.0.
  • A function that takes out what its object owns can stand for
    one of an interface. A call through the interface is then held to
    the same guards as a call on the object: only the owner may make
    it, and not in a loop that is looking at what it takes.
  • owned interface: each object that is one has one owner, with a
    collector too. Only an owned class can be one, and an owned class can only be one.

See
docs/interfaces.md
and 58.20 to 58.23 of the decisions.

Cleaning up when a block ends

owned class Selected is Resource, with a function release(self),
says that something must be put back: a chip-select line, a lock, an
open file. release runs when the owner of the object ends, on every
way out of its block: the end, return (after its value is worked
out), break, continue, and an error passing through, which goes
on unchanged. Of two, the one made last is released first; one that
was given away is released by whoever has it. program.exit and a
firmware fault release nothing. In this version a resource lives in a
let or a parameter, and every other place is refused with a message
that says what to write. Under zeno test the top of the file ends
after its last test. A program that never names Resource is built
as it was, to the byte. See
docs/resource.md
and 59.1 to 59.5 of the decisions.

A file in pieces

files.read_from(path) gives a files.Reader, which reads a file a
line at a time with read_line() or for line in reader, or a few
bytes at a time with read_bytes(count). files.write_to(path) and
files.append_to(path) give a files.Writer, with write(text) and
write_bytes(bytes). Both are resources: the file is closed when the
owner ends, so there is no close. Each write reaches the system
before it returns, so a full disk is a FileError at that write.
The two classes are written in Zeno, in library/files.zeno, and a
program that does not use them is built as it was, to the byte. See
docs/files-in-pieces.md
and 59.6 and 59.7 of the decisions.

Folders

files.list(folder) gives the names in a folder as a list[str],
sorted by the numbers of their characters, so that every engine and
every target gives the same list on Linux, macOS and Windows.
files.make_folder(path) makes a folder and those above it, and is
no error when the folder is there already. Both raise FileError.
files.join(first, second) puts one / between two parts of a path,
and is written in Zeno, in library/files.zeno. A program that uses
none of the three is built as it was, to the byte. In a program built
through C or LLVM on Windows a file's name goes through the system's
code page, as fopen takes it, so a name with letters that page lacks
cannot be opened there; zeno run takes any name. See
docs/folders.md
and 59.20 to 59.23 of the decisions.

A message on assert

assert reply == Reply.Ack, f"the board answered {reply} to the reset":
after a comma, the text that a failed assert prints, on a line of
its own above "this is false...", which stays. It must be text, and
is worked out only when the assert fails. An assert with no comma
is as it was. See
docs/testing.md
and 60.1 of the decisions.

Tests of a compiled program

zeno test --build compiles each file with its tests in it, as zeno build would, runs the program, and prints what zeno test prints,
line for line. It takes --firmware, --no-collector, --llvm,
--release and --board, so a test is held to the rules of the build
it is for: a test that shares a list is refused with no collector, as
the program would be. With --board it builds ring-tests.elf for
the board, which prints the lines and the totals itself; on QEMU's
Cortex-M3 it prints what zeno test prints. An assert in a function
written inside a test is refused under --build, and a fault of a
firmware build stops the test program, which the command then names.
zeno test without --build is what it was, and no other program has
a line more. See
docs/testing.md
and 60.2 of the decisions.

The book and the history

The Zeno Book is up to date with this
release. Every chapter that a feature touches says it, with programs
that are run as the book is built: several values in the chapter on
functions; a function that raises, and a method, as a value; bounds,
generic enums and generic interfaces in the chapter on generics; a
default, taking out and owned interface in the chapter on interfaces;
take from a field, and cleaning up when a block ends, in the chapter
on ownership; folders and a file in pieces in the chapter on reading
and writing; a message on assert and tests of the compiled program
in the chapter on testing; and the pool's size in the chapter on
building with no collector. The appendix of what Zeno does not have
yet has lost what this release added. It is 323 pages, and the 378
programs and 103 commands in it were run by this release as the book
was built.

HISTORY.md
has every commit of this release under it, and the website shows it at
zeno-lang.org/history.

Fixed

A function that tested a parameter that may be none and then read a
field of it read the field before the test in every build of C and
LLVM of 0.7.0, and so read through NULL when given none. It reads
it after the test now.

With no collector, a look at an object of a generic class given to a
parameter of a generic function, as in size(s) with function size[T](s: Stack[T]), was refused with "should be Stack[T], but this
is a Stack[int] that is only looked at". It builds now (58.2).

Everything a program wrote for 0.7.0 means what it meant.

The archives

Machine File
Linux, x86-64: most PCs and servers zeno-0.8.0-linux-x86_64.tar.gz
Linux, ARM64: a Raspberry Pi 3, 4 or 5 with a 64-bit system, ARM servers zeno-0.8.0-linux-arm64.tar.gz
Linux, 32-bit ARMv7: a Raspberry Pi 2 or later with a 32-bit system zeno-0.8.0-linux-armv7.tar.gz
Linux, 32-bit ARMv6: a Raspberry Pi 1 or Zero zeno-0.8.0-linux-armv6.tar.gz
Linux, 32-bit x86 zeno-0.8.0-linux-x86.tar.gz
macOS, Apple silicon zeno-0.8.0-macos-arm64.tar.gz
macOS, Intel zeno-0.8.0-macos-x86_64.tar.gz
Windows, x86-64 zeno-0.8.0-windows-x86_64.zip
Windows, 32-bit x86 zeno-0.8.0-windows-x86.zip
Windows, ARM64 zeno-0.8.0-windows-arm64.zip

Unpack it and put zeno (zeno.exe on Windows) somewhere on your
PATH. To build web pages, put zeno.wasm from the same folder
beside it. The folder also holds the docs, the examples, the two
boards and the editor setup.

tar -xzf zeno-0.8.0-linux-x86_64.tar.gz
cd zeno-0.8.0-linux-x86_64
./zeno --version
./zeno build --release examples/hello.zeno && ./hello
./zeno build --target py examples/hello.zeno && python3 hello.py

On macOS, a program downloaded with a browser is held back because
Apple has not signed it. xattr -d com.apple.quarantine zeno lets it
run.

zeno build hands the C it writes to a C compiler, so it needs one:
cc, gcc or clang, whichever it finds first, or the one CC
names. zeno build --board needs the compiler the board names: for
the two boards that come with Zeno, arm-none-eabi-gcc, and QEMU to
run the result. zeno build --llvm needs clang. zeno fetch,
zeno search and zeno publish need git. zeno build --target needs
nothing to write the file (but wasm, which needs Rust), and the
language to run it. import python, node, java, ruby, php,
lua and csharp need that language, and import c a C compiler.
zeno build --web and everything else need nothing.

What was checked

As for 0.7.0, every build but the Windows one for ARM64 was run before
it was released, and each one that was run also built the page of
examples/todo.zeno and wrote examples/hello.zeno in fourteen
languages. The whole test suite passes on Linux x86-64 (743
tests), on macOS on Apple silicon (741, one of them left aside) and on
Windows x86-64 (740, one left aside): a few tests are of one system
only.

On the two boards. Every example, every sample of the book and
the corner programs that a build with no collector takes were built
for both boards and run in QEMU, and each did there what it does on a
computer: 262 of 262 programs on boards/qemu-cortex-m3 and 242
of 242 on boards/lm3s6965evb, and with --minimal 246 of 246 and
227 of 227. Nothing was run on a real board, as for 0.7.0: what
QEMU does not emulate is written from the data sheet and has been
tried nowhere.

In plain C. The C of 302 programs with a collector, 276 with
--owned and 276 with --no-collector was compiled as it is, as
plain C read by the standard of 1999 (gcc, and Clang for the examples
and the corner programs, -std=c99 -pedantic-errors), and by tcc
0.9.27, and they do the same. No program has been built by IAR's,
Keil's or a chip maker's compiler.

The fifteen targets were checked on Linux x86-64, on GitHub's machine,
with the newest Node, TypeScript, Python, PHP, Lua, Ruby, Dart,
Kotlin, Go, Java, .NET, g++ and Rust: 400 of 400 programs each, and
382 of 382 for the page, which is opened in Chromium. --minimal was
checked there and on macOS on 276 programs with a collector, and on
258 to 273 in the other three kinds of build.

The speed was not compared with 0.7.0 for this release, on any
machine. Nothing in it was meant to make a program faster or slower,
but that was not measured.

The setup program for Windows was installed, run and uninstalled on a
Windows machine, and install.sh the same on Linux and on macOS. Each
package was installed, run and removed: the .deb, the snap and the
flatpak on Ubuntu, the pacman package in Arch, and the Homebrew
formula on macOS.