[Oberon] Modula2 vs Oberon IMPORT

Chris Burrows chris at cfbsoftware.com
Sat Jan 8 07:38:47 CET 2011

> -----Original Message-----
> From: Duke Normandin [mailto:dukeofperl at ml1.net] 
> Sent: Saturday, 8 January 2011 2:09 PM
> To: Oberon List
> Subject: [Oberon] Modula2 vs Oberon IMPORT
> Happy New Year Everybody!

A Happy New Year to you also!

> I see that in Modula only the required procedures are IMPORTed, like:
> FROM STextIO IMPORT WriteString, WriteLn;
> Conversely, in Oberon, the whole Module has to be IMPORTed in order to
> get to use the equivalent procedures.
> It would seem to me that Oberon "programs" would be that much more
> "bloated" with unnecessary code. Am I correct in this conclusion? 

No - you are not correct. If an Oberon program only referenced:


then a *smart* Oberon linker / loader does not need to load any more code
than the Modula-2 example. Whether the Oberon or Modula-2 system loads the
whole module or just the used procedures depends on the capabilities of the
system's linker / loader and the execution environment.

> Is
> there a way to selectively IMPORT procedures in Oberon? It doesn't
> appear to me to be possible.

One reason for wanting to use the selective FROM .. IMPORT in Modula-2 is so
that you can call WriteString and WriteLn in your program without having to
prefix every call with the module name STextIO.

To do something similar in Oberon you could use procedure variables to
declare the names you wanted to use e.g. 

  WriteLn: PROCEDURE ();

and then in the module initialisation code you would assign the aliases:

  WriteString := STextIO.WriteString;
  WriteLn := STextIO.WriteLn;

Chris Burrows

CFB Software
Astrobe v3.2: ARM Oberon-07 Development System

More information about the Oberon mailing list