The ModulaTor logo 7KB

The ModulaTor

Oberon-2 and Modula-2 Technical Publication

The ModulaTor
Erlangen's First Independent Modula-2 Journal! Nr. 6/Jul-1991 
_____________________________________________________________

Comparison of the Edison & Modula-2 Language 

by Guenter Dotzel, ModulaWare GmbH, Wilhelmstr. 17A, W-8520 Erlangen/F.R.G. 

2nd revised ed., 03-Jun-1993 

The following table contains a comparison of the programming languages Edison (EEK 
V1.0) and Modula-2 (MVR V3.12). The topics covered are features which are important 
for modern, modular and structured programming languages. Other features have been 
compared because they are either different in both languages or not available in either 
one. 

                           Edison             Modula-2 (MVR on VAX/VMS)
__________________________________________________________________________________________________ 
keywords                    28                40
__________________________________________________________________________________________________ 
strong typing              yes                yes
__________________________________________________________________________________________________ 
case sensitive              no                yes
__________________________________________________________________________________________________ 
standard data types          7                 8
__________________________________________________________________________________________________ 
integer, real,             yes                no
longrealexpr
__________________________________________________________________________________________________ 
complex, longcomplex       yes                no
expression compatibility
__________________________________________________________________________________________________ 
system-specific data types   0                10
__________________________________________________________________________________________________ 
standard functions           0 (0)            17
__________________________________________________________________________________________________ 
system-specific standard fu  0                12
__________________________________________________________________________________________________ 
standard procedures          0                 7
__________________________________________________________________________________________________ 
system-specific standard pr  0                 2
__________________________________________________________________________________________________ 
modules                     yes               yes
__________________________________________________________________________________________________ 
modules local to procedures yes               yes
__________________________________________________________________________________________________ 
module initialization       yes               yes
__________________________________________________________________________________________________ 
subranges                    no               yes
__________________________________________________________________________________________________ 
enumerations                yes               yes
__________________________________________________________________________________________________ 
unsigned arithmetic          no               yes
__________________________________________________________________________________________________ 
complex number arithmetic   yes               yes
__________________________________________________________________________________________________ 
sets (max. size)            yes (256)         yes (128)
__________________________________________________________________________________________________ 
string constructors         yes               yes (ISO-M2 only)
__________________________________________________________________________________________________ 
pointers                     no               yes
__________________________________________________________________________________________________ 
variant records              no               yes
__________________________________________________________________________________________________ 
case-statement               no               yes
__________________________________________________________________________________________________ 
value & variable formal                       
procedure parameters        yes               yes
__________________________________________________________________________________________________ 
recursion                   yes               yes
__________________________________________________________________________________________________ 
procedure type parameters   yes               yes (1)
__________________________________________________________________________________________________ 
procedure variables          no               yes (1)
__________________________________________________________________________________________________ 
multiprogramming            yes (cobegin/when)no (only basic coroutine handling)
__________________________________________________________________________________________________ 
declare before use          yes               no
__________________________________________________________________________________________________ 
goto                         no               no
__________________________________________________________________________________________________ 
loop constructs              1 (while/else)    4 (while, repeat, loop, for)
__________________________________________________________________________________________________ 
record & array constructors yes               yes
__________________________________________________________________________________________________ 
type of function return     any               standard data types only (up-to 16 bytes)
                                              from MVR V4.02 (as in ISO M2): any type
__________________________________________________________________________________________________ 
indexing, dereferencing     no               no
& field selection of re-
typed variables
__________________________________________________________________________________________________ 
type cast for expressions   yes (2)           yes (2) (via CAST (Type, expression))
__________________________________________________________________________________________________ 
re-typed variables          yes               no (3)
__________________________________________________________________________________________________ 
indexing & field selection  yes               no
of re-typed variables
__________________________________________________________________________________________________ 
requires program linking     no               yes
__________________________________________________________________________________________________ 
separate compilation        yes (4)           yes (definition and implementation module)
__________________________________________________________________________________________________ 
generated code              e-code             native code (VAX/VMS object file format)
__________________________________________________________________________________________________ 
symbolic debugger            no (error/line #)yes (standard VMS-debugger supported)
__________________________________________________________________________________________________ 
overlays                    yes (4)           yes (via VMS-linker, shareable-images too)
__________________________________________________________________________________________________ 
built-in I/O                 no (5)           no (via standard I/O-library modules)
__________________________________________________________________________________________________ 
built-in math                no (5)           no (via standard math-library modules)
__________________________________________________________________________________________________ 
operating system calls       no (5)           no (via foreign definition modules)
__________________________________________________________________________________________________ 
layered product calls        no (6)           no (via foreign definition modules)
(XWindows, GKS, RMS, ...)
__________________________________________________________________________________________________ 
portability of programs     e-code            recompile on new target
__________________________________________________________________________________________________ 

Notes: 

0. Standard function names are equivalent to standard type names in Edison, e.g.: assume the declaration 
var ch: char; i: int; then the character with the ordinal number i is char(i). The equivalent in Modula-2 is VAR 
ch: CHAR; i: INTEGER; where the character with the ordinal number i is CHR(i). 

1. Only procedures declared at global level (i.e. not within procedures) may be assigned or substituted as 
actual parameter in a procedure call. 

2. Only for same size variables. 

3. In Edison a re-typed variable or factor is indicated syntactically by ':' typename; there is a difference in 
re-typing an expression or a variable. The first gives the value of an expression a new type and the latter 
re-types the variable to the new type. Variable:Type is a variable of type Type which may be substituted in a 
procedure call in place of a variable parameter. In Edison, re-typed variables may also be indexed if the new 
type is an array or in case of a record type, a field may be selected.
 

In Modula-2 the so-called type transfer is Type(Variable) (or SYSTEM.CAST (Type, Variable) in 
ISO-Modula-2) is an expression of type Type. 

4. So-called library procedures may be called as procedures with any number of optional parameters of any 
type. In Edison any program is a procedure. An executable program is a procedure with a standardized 
procedure heading (formal parameter list, which is called prefix) which is defined by the interpreter. Library 
procedures may be compiled separately and called at run-time from any program. 

5. All I/O-, system-time/date- and math-procedures are contained in the standard prefix. The Edison objects 
declared in the prefix are compatible to the definitions of those found in the ISO-Modula-2 Standard Library. 

6. All additional objects (constants, types, variables and procedures) of any layered product or software 
written in other language than Edison can be used/called by extending the prefix definition (see also notes 4, 
5 and 7). The new objects must be installed into the e-code interpreter by calling an installation procedure. 
Only the interpreter must then be re-linked once to the installation code. To avoid re-linking at all, it is also 
possible to use static or dynamic (run-time) shareable-image binding, if the operating system is flexible 
enough to support this (as in fact VMS does). Edison programs are compiled to e-code and executed; pre- or 
re-linking is neither required nor possible. All operating-system dependent or native-code stuff is contained in 
and hidden by the installation process. 

7. The preliminary standard prefix definition for Edison programs: 

"Edison PREFIX, (c) 1991 ModulaWare
EEK V1.0, 29-Jul-1991

Standard edison-prefix, which shall be copied above every edison source file,
when the resulting program is directly called by the Edison-interpreter.
So called library procedures may have arbitrary prefix definitions."

"EDISON-System"
const maxcode = 62500   "int"
const maxtoken = 509    "char"
const maxline = 509     "char"
const maxstring = 256   "char"
const maxname = 254     "char"
const maxloc = 127      "int"

"RealMath"
const PI = 3.1415926535897932385
const Exp1 = 2.7182818285450452354

"Strings"
array String1[1:1] (char)
const BigStringCapacity = 256
array BigString[1:BigStringCapacity] (char)
enum CompareResult (less, equal, greater)

"IO"
enum Flags (textFlag, binaryFlag, readFlag, writeFlag, useOldFlag)
enum ReadResults (allRight, outOfRange, wrongFormat, noData, noRoom)
enum Results (done, wrongNameFormat, tooManyOpenFiles, wrongPermissions, 
  noRoomOnDevice, noSuchFile, fileExists, wrongFileType, noTextOperations,
  noBinaryOperations, noMixedOperations, otherProblem)

array Loc[0: maxloc] (int)
array Line [0: maxline] (char)
array Token[0: maxtoken] (char)
array String[1: maxstring] (char)
array FileName[0: maxname] (char)
record FilePos (pos1, pos2: int)
record ChanId (chan: int)                
set FlagSet (Flags)
record ClockData (year, month, day, hour, minute, second, fractions, zone: int)
array programcode[1: maxcode] (int)
record libprogram(progname: FileName; progcode: programcode)

set charset (char)

proc anyprogram(
  maxreal: real; minreal: real;
  maxlongreal: longreal; minlongreal: longreal;
  maxchar: char; minchar: char;
  maxint: int; minint: int;
  maxrow, maxcolumn: int;

  proc odd (i: int): bool;
  proc cap (ch: char): char;
  proc shift (i, n: int): int;
  proc rotate (i, n: int): int;

  proc abs (r: real): real;
  proc labs (l: longreal): longreal;
  proc iabs (i: int): int;

  proc complx (rea, ima: real): complex;
  proc rea (c: complex): real;
  proc ima (c: complex): real;

  proc lcomplx (lrea, lima: longreal): longcomplex;
  proc lrea (c: longcomplex): longreal;
  proc lima (c: longcomplex): longreal;

  proc sqrt (x: real): real;
  proc lsqrt (x: longreal): longreal;
  proc exp (x: real): real;
  proc lexp (x: longreal): longreal;
  proc ln (x: real): real;
  proc lln (x: longreal): longreal;
  proc sin (x: real): real;
  proc lsin (x: longreal): longreal;
  proc cos (x: real): real;
  proc lcos (x: longreal): longreal;
  proc tan (x: real): real;
  proc ltan (x: longreal): longreal;
  proc arcsin (x: real): real;
  proc larcsin (x: longreal): longreal;
  proc arccos (x: real): real;
  proc larccos (x: longreal): longreal;
  proc arctan (x: real): real;
  proc larctan (x: longreal): longreal;
  proc power (x, y: real): real;
  proc lpower (x, y: longreal): longreal;
  proc round (x: real): int;
  proc lround (x: longreal): int;

  proc cabs (cmplx: complex): real;
  proc lcabs (cmplx: longcomplex): longreal;
  proc carg (cmplx: complex): real;
  proc lcarg (cmplx: longcomplex): longreal;
  proc cexp (cmplx: complex): complex;
  proc lcexp (cmplx: longcomplex): longcomplex;
  proc cln (cmplx: complex): complex;
  proc lcln (cmplx: longcomplex): longcomplex;
  proc cpolar (abs, arg: real): complex;
  proc lcpolar (abs, arg: longreal): longcomplex;
  proc csqrt (cmplx: complex): complex;
  proc lcsqrt (cmplx: longcomplex): longcomplex;

  proc Length (str: BigString): int;
  proc CanAssignAll (SourceLength: int; var Destination: BigString): bool;
  proc Assign (Source: BigString; var Destination: BigString);
  proc CanExtractAll (SourceLength, StartIndex, NumberToExtract: int; 
    var Destination: BigString): bool;
  proc Extract (Source: BigString; StartIndex, NumberToExtract: int; 
    var Destination: BigString);
  proc CanDeleteAll (SourceLength, StartIndex, NumberToDelete: int): bool;
  proc Delete (var StringValue: BigString; StartIndex, NumberToDelete: int);
  proc CanInsertAll (SourceLength, StartIndex: int; 
    var Destination: BigString): bool;
  proc Insert (Source: BigString; StartIndex: int; var Destination: BigString);
  proc CanReplaceAll (SourceLength, StartIndex: int; 
    var Destination: BigString): bool;
  proc Replace (Source: BigString; StartIndex: int; var Destination: BigString);
  proc CanAppendAll (SourceLength: int; var Destination: BigString): bool;
  proc Append (Source: BigString; var Destination: BigString);
  proc Capitalize (var StringVar: BigString);
  proc Compare (StringVal1, StringVal2: BigString): CompareResult;
  proc FindNext (Pattern, StringValue: BigString; StartIndex: int;
    var PatternFound: bool; var PosOfPattern: int);
  proc FindPrev (Pattern, StringValue: BigString; StartIndex: int;
    var PatternFound: bool; var PosOfPattern: int);
  proc FindDiff (StringVal1, StringVal2: BigString;
    var DifferenceFound: bool; var PosOfDifference: int);

  proc select (normal: bool);
  proc cursor (row, column: int);
  proc erase;
  proc subset (first, last: char): charset;
  proc load (title: FileName): libprogram;
  proc Rename (old, new: FileName);
  proc DeleteFile (title: FileName);

  proc Look (cid: ChanId; var ch: char);
  proc TSkip (cid: ChanId);
  proc SkipLn(cid: ChanId);
  proc WriteLn(cid: ChanId);
  proc SeenLn (cid: ChanId): bool;
  proc SeenEnd (cid: ChanId): bool;
  proc LastResult (cid: ChanId): ReadResults;
  proc ReadChar (cid: ChanId; var c: char);
  proc ReadToken (cid: ChanId; var s: Token);
  proc ReadLine (cid: ChanId; var s: Line);
  proc ReadString (cid: ChanId; var s: BigString);
  proc ReadFileName (cid: ChanId; var name: FileName);
  proc WriteChar (cid: ChanId; c: char);
  proc WriteString (cid: ChanId; s: BigString);
  proc WriteFileName (cid: ChanId; name: FileName);
  proc WriteLine (cid: ChanId; s: Line);
  proc ReadInt (cid: ChanId; var i: int);
  proc WriteInt (cid: ChanId; i: int);
  proc ReadWord (cid: ChanId; var w: int);
  proc WriteWord (cid: ChanId; w: int);
  proc ReadReal (cid: ChanId; var x: real);
  proc WriteReal (cid: ChanId; x: real);
  proc ReadLongReal (cid: ChanId; var x: longreal);
  proc WriteLongReal (cid: ChanId; x: longreal); 
  proc Read (cid: ChanId; var to: Loc);
  proc Write (cid: ChanId; var from: Loc);
  proc Open (var cid: ChanId; name: FileName; flags: FlagSet; var res: Results);
  proc OpenWrite (var cid: ChanId; name: FileName; flags: FlagSet; var res: Results);
  proc OpenAppend (var cid: ChanId; name: FileName; flags: FlagSet; var res: Results);
  proc OpenRead (var cid: ChanId; name: FileName; flags: FlagSet; var res: Results);
  proc OpenOld (var cid: ChanId; name: FileName; flags: FlagSet; var res: Results);
  proc OpenClean (var cid: ChanId; name: FileName; flags: FlagSet; var res: Results);
  proc IsSeqFile (cid: ChanId): bool;
  proc IsRewFile (cid: ChanId): bool;
  proc IsRndFile (cid: ChanId): bool;
  proc Close (var cid: ChanId);
  proc Reread (cid: ChanId);
  proc Rewrite (cid: ChanId);
  proc StartPos (cid: ChanId): FilePos;
  proc CurrentPos (cid: ChanId): FilePos;
  proc EndPos (cid: ChanId): FilePos;
  proc NewPos (offset, chunkSize: ChanId; from: FilePos): FilePos;
  proc SetPos (cid: ChanId; pos: FilePos);
  proc InChan: ChanId; 
  proc OutChan: ChanId; 
  proc ErrChan: ChanId; 
  proc NullChan: ChanId;
  proc ArgChan: ChanId;
  proc IsArg: bool;
  proc NextArg;
  proc SInp: ChanId;
  proc SOut: ChanId;
  proc SetSInp (cid: ChanId);
  proc SetSOut (cid: ChanId);
  proc IsOpen (cid: ChanId): bool;
  proc CanRead (cid: ChanId): bool;
  proc CanWrite (cid: ChanId): bool;
  proc DoesText (cid: ChanId): bool;
  proc DoesBinary (cid: ChanId): bool;
  proc IsInteractive (cid: ChanId): bool;
  proc IsEchoing (cid: ChanId): bool;
  proc GetName (cid: ChanId; var name: FileName);
  proc Flush (cid: ChanId);
  proc CanClose (cid: ChanId): bool;

  proc CanGetClock: bool;
  proc CanSetClock: bool;
  proc IsValidClockData (data: ClockData): bool;
  proc GetClock (var userData: ClockData);
  proc SetClock (userData: ClockData))
 \251 (1991) by Guenter Dotzel, Erlangen (File [doc]edsm2c.dw2 02-May-1991, revised 03-Jun-1993) 

__________________________________________________________________________________________________ 


IMPRESSUM: The ModulaTor is an unrefereed journal. Technical papers are to be taken as working papers and personal rather than organizational statements. Items are printed at the discretion of the Editor based upon his judgement on the interest and relevancy to the readership. Letters, announcements, and other items of professional interest are selected on the same basis. Office of publication: The Editor of The ModulaTor is Guenter Dotzel; he can be reached by tel/fax: [removed due to abuse] or by mailto:[email deleted due to spam]
  ModulaWare home page   The ModulaTor download    [Any browser]

Webdesign by www.otolo.com/webworx, 14-Jul-1998