Linux Native Oberon : programming

Time to see how programming goes. Of course you already know so, since you read the tutorials of LNO. Still, for the odd one out, who skipped that part, here is some extra information.

Mind you: my first nontrivial DOS program in a serious language (i.e. 8086 assembler) took me weeks to get it running. It didn't do what I anticipated, but at least it ran (it trashed my working directory, but that's another story) and that was progress in itself.

Same here: Oberon is a SYSTEM, more than DOS and Windows together. Not as much as Unix, but still. So keep this in mind. Some things may look awkward or stupid. Just accept them for the time being. Later you will learn to appreciate it. And learn to live with it. Or get back to C++ again. Drats. Time to wash my mouth again.

LNO programming : executables

DOS (and its successor Windows) can carry out any file as a command, when the extension is right. In 1977 that was a novel idea. And the makers of virusses still cherish the decision.

In Unix, any kind of file can be executable, as long ast it is MARKED as being executable. And if the file is brought in via an insecure method, it must be declared executable by its user. That is an advantage, loathed by virusmakers.

In Oberon, things are even simpler. There are no commands. There are libraries of functions and each function can be called from anywhere else. And the system protects itself against newcomers, as we are to find out.

LNO programming : Hello.Mod

Our first example is the obligatory "Hello world" program. And we're lucky: it is already part of the implementation. So go ahead as follows:

You can now do all you need from this same file, as we see on the right. The actual program source is a minute fraction of text, embedded between two huge comments. But it is a syntactical good approach and it gets the job done, while relaying the message.

The actual source looks like this:

	MODULE Hello;	(** Portable *)

	  PROCEDURE World*;
	    Out.String ("Hello World!");
	    Out.Ln ()
	  END World;
	END Hello.
Rather straighforward, for the seasoned Modula-2 programmer.

Now just do as you are told in the bulleted list below the program sourcecode. You should learn a lot from doing just what Niklaus told you.

Now, that was an easy one. Time for something of our own hand.

LNO programming : Hit.Mod

On the left we see the source code of our new library called Hit. This module was written by me, the Modula-2 guy, fluent in Mocka and FST.

As you can see in the right, my years of experience paid off: no compilation errors. A clean compile. I'm proud of myself.

Time to test the routine: enter the name (Hit.Here) somewhere in a viewer and MM on it. See what happens?

I MM-ed the command twice. And I got the Hideeho once and the error twice. So the MAIN routine of the library is called only once, when the library is called for the first time. As was to be expected.

See the error? It says 'Here not found'. But it's there. Apparently the seasoned Modula-2 guy should have read the book.

LNO programming : Visibility

Oberon does not use seperate DEFINITION MODULES, like our beloved Modula-2 does. Instead it uses STAR markers inside the source text. On the left we see what was changed (look at the end of the PROCEDURE declarations): a tiny asterisk was added.

Hmm. If it doesn't kill you, it just makes you ..... stranger....

Here is new.
There is new.
But a new symbol table could not be made. Apparently there is some kind of safety mechanism built into Oberon to prevent accidentaly overwriting system resources. Not bad.

The trick lies in the documentation we should have read: the module Hit was loaded before and from then it was kept in memory. So that's what we're going to do: System.Free Hit. See what that does.

Here and There are new again. But the symbol table is still not overwritable. Apparently I should have dug deeper in the documents. The trick is a flag for the compiler: '/s'.

This seems to do the trick. We have a clean compile. Now let's see if we start the functions in the Qualified Way. As you see, it works:

  1. I start 'Hit.There':
  2. I start 'Hit.Here'
And that's it. Now it works as expected.

LNO programming : Rounding up

Don't forget to save the file ("Store") otherwise your work will be lost. This is a grown-ups operating system. Not for the faint hearted. It's even worse than Unix.

LNO saves the files in Native Oberon format, so you cannot process the LNO files with a Linux wordprocessor or editor. Look here:

You can recognize the body of the program. Lines are ended by ^M (ASCII.CR). But most problematic: there is some kind of status information in the front of the file...

Page created 3 January 2009,