The 07z dialect

Only what is necessary. Everything original kept.

Oberon 07z is Wirth's Oberon-07, as his 2016 report defines it, with a short list of additions. Each one closes a gap a systems program can't work around. Here is the thinking behind each, and what we left alone.

The principle

We only did what is necessary, and preserved what is original.

Wirth spent his career taking things out of languages, and Oberon-07 is the result: a language that is complete because there is nothing left to remove. A dialect that treated it as a starting point for a bigger language would lose the one thing that makes it worth using.

So the test for every addition was the same: is there something a systems program must do that Oberon-07 gives it no way to do? If the answer was no, it stayed out. When the answer was yes, we added the smallest thing that closes the gap, written in Oberon's own style, and left the rest of the language exactly as the report has it.

The compiler holds us to it. Its coverage of the language is tracked section by section against Wirth's report, and the 07z additions are tracked separately, so each one stays visible as an addition rather than blurring into the language.

64-bit integers

The gap. Oberon-07 has one integer type, and in Oberon 07z it is 32 bits. File sizes, byte offsets, timestamps in milliseconds and counters routinely need more.

The addition. LONGINT, a signed 64-bit integer, beside the report's INTEGER. An INTEGER never becomes a LONGINT silently: the compiler refuses the transfer unless the program writes LONG(n).

What stays. INTEGER is still the everyday integer, and arithmetic on it is still checked.

UTF-8 text

The gap. Text today is UTF-8: in files, on the network and in source code. A systems language that can't say so leaves every program to guess.

The addition. Source is UTF-8, and a plain string literal is UTF-8 text. Text operations count characters, so the fourth character of "café" is é, while diagnostics about raw input give byte offsets.

What stays. Text still lives in ARRAY OF CHAR, in storage the caller owns. There is no hidden string type that allocates behind the program's back.

Module paths and aliases

The gap. In Oberon-07 a module's name is a single identifier, so every module of every library shares one flat namespace. That works for one system. It doesn't work once programs combine libraries from different authors.

The addition. A module name can have dotted parts, like IO.Reader or Net.TCP, and an import can give it a short alias:

IO/Reader.ob
MODULE IO.Reader;
IMPORT Console := IO.Console, TCP := Net.TCPHost;

What stays. Imports are still explicit, at the top of the module, and every use of an imported name is still qualified. An alias only shortens the qualifier.

One module, several files

The gap. In Oberon-07 a module is one file. A large module becomes one very long file, and there's no way to keep its parts apart without splitting it into several modules, which changes its interface.

The addition. A module can be written across several files. Each file starts with the same MODULE line, the files share the module's private names, and together they compile to one module with one interface. Modules shows how, and what it makes possible.

What stays. To everyone who imports it, a module is still exactly one module.

Calls into C

The gap. A systems program has to talk to the operating system and to the libraries already written for it, and on today's systems those speak C.

The addition. EXTERN "C" declares a C function, which is then called like any other procedure. The standard library uses it for the console, files, clocks and sockets, so Oberon code above it never needs to.

IO/Console.ob
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;

What stays. The foreign calls are declared in Oberon, with Oberon types, and kept to the modules that need them.

FREE and DEFER

The gap. Oberon-07 has NEW to allocate, and relies on a garbage collector to take memory back. A systems language without a collector has to give memory back itself, and has to do it on every way out of a procedure.

The addition. FREE releases what NEW allocated. DEFER registers a statement to run when the procedure returns, so a release, a close or any other cleanup is written once, right next to what it cleans up:

Main.ob
PROCEDURE DumpOpened(VAR r: R.Reader): INTEGER;
BEGIN DEFER R.Close(r); RETURN Hexdump.Dump(r, FALSE) END DumpOpened;

What stays. NEW works as the report describes, and new storage starts zeroed.

What we left alone

Everything else is Wirth's. Oberon 07z adds no generics, no exceptions, no classes beyond the report's type extension, no operator overloading, no macros and no preprocessor. The report's keywords are reserved exactly as he wrote them, and its statements, types and scope rules are unchanged.

If you know Oberon-07, you know Oberon 07z. The additions above are the whole difference.

Next: modules, packages, tests and platforms →