[Oberon] Modula2 vs Oberon IMPORT

Chris Burrows chris at cfbsoftware.com
Sat Jan 8 08:00:54 CET 2011


> -----Original Message-----
> From: Douglas G. Danforth [mailto:danforth at greenwoodfarm.com] 
> Sent: Saturday, 8 January 2011 5:18 PM
> To: ETH Oberon and related systems
> Subject: Re: [Oberon] Modula2 vs Oberon IMPORT
> 
> > 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.
> >
> > VAR
> >    WriteString: PROCEDURE(s: ARRAY OF CHAR);
> >    WriteLn: PROCEDURE ();
> >
> > and then in the module initialisation code you would assign 
> the aliases:
> >
> > BEGIN
> >    WriteString := STextIO.WriteString;
> >    WriteLn := STextIO.WriteLn;
> >    ...
> 
> The MAINSAIL language does not require imported procedures to be 
> prefixed with the module name.
> I have found Oberon to be far superior.  

I use both approaches in Oberon. 95% of the time I qualify calls with the
module name. The other 5% of the time is when I have hundreds of calls to a
very common function that is unlikley to be mistaken for anything else.

> It makes immediately obvious 
> what function is being referenced.
> If X is present in two module both imported then referencing X is 
> ambibuous without the module prefix.
> 

That is another of the reasons why Modula-2 has the FROM .. IMPORT
construct. You can import two different modules that both contain X but make
it clear which module an unqualified X is being IMPORTed FROM. 

Regards,
Chris
 





More information about the Oberon mailing list