64-bit integers
LONGINT sits beside the Report's INTEGER, for the values that need 64 bits.
value := LONG(-42)
Oberon 07z
Oberon 07z is Niklaus Wirth's Oberon-07 as a systems language: compiled to native code, with no garbage collector, and with the few things today's programs need: 64-bit integers, UTF-8 text, module paths, cleanup with DEFER, and calls into C.
MODULE Main;
IMPORT R := IO.Reader, Hexdump;
PROCEDURE main(): INTEGER;
VAR r: R.Reader;
BEGIN R.StandardInput(r); RETURN Hexdump.Dump(r, TRUE) END main;
END Main.
Why Oberon
Wirth defined Oberon-07 in one short report: modules, procedures, records, arrays and pointers, and very little else. There's one way to write most things, so code reads the same to everyone who knows the language.
Array indexes are checked. Integer arithmetic stops on overflow instead of wrapping, and new storage starts zeroed. Arenas give dynamic bytes an explicit lifetime, and refuse a block once its arena is released.
The compiler builds standalone executables through LLVM, for Linux on x86-64. There's no garbage collector: memory comes from NEW and goes back with FREE, and a program can link a C object and call into it like any other procedure.
What 07z adds
LONGINT sits beside the Report's INTEGER, for the values that need 64 bits.
value := LONG(-42)
Source and text are UTF-8. Positions count characters, so the fourth character of "café" is é.
Text.CharAt("café", 3, ch)
Modules nest under dotted names, and an import can take a short alias.
IMPORT R := IO.Reader, Console := IO.Console;
DEFERRegister the cleanup next to the thing it cleans up. It runs when the procedure returns.
PROCEDURE DumpOpened(VAR r: R.Reader): INTEGER;
BEGIN DEFER R.Close(r); RETURN Hexdump.Dump(r, FALSE) END DumpOpened;
Declare a C function and call it like any procedure. The standard library's console is written this way.
MODULE IO.Console;
EXTERN "C" PROCEDURE obHostStdout(src: ARRAY OF BYTE; at: INTEGER; count: INTEGER): INTEGER;
EXTERN "C" PROCEDURE obHostStderr(src: ARRAY OF BYTE; at: INTEGER; count: INTEGER): INTEGER;
The library
Every module works on storage the caller owns, or on an arena the caller chose. Failures come back as named statuses, and each operation says what a failure leaves untouched.
Get Oberon 07z
An Oberon 07z program is a Gritpack package. Its manifest names the dialect, and the standard library, TOML and HTTP come in as ordinary dependencies: oberon07z-stdlib, oberon07z-toml and oberon07z-http.
Write to info@frogfish.io, and we'll set you up.
[package]
name = "hello"
version = "0.1.0"
dialect = "oberon/07z"
encoding = "source/utf8"
files = ["src/**"]
[dependencies]
oberon07z-stdlib = "0.1.0"