Jump to content

Modula-3 programming language

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 213.7.125.236 (talk) at 13:47, 4 July 2004 (more M3 features). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Modula-3 is an extension of the Modula-2 programming language created out by a joint effort by engineers at the DEC Systems Research Center and Olivetti in the late 1980s. Modula-3 aimed to continue the Pascal tradition of type safety, while introducing new constructs for practical real-world programming. In particular Modula-3 adds support for generic modules (kind of templates), multithreading, exception handling, garbage collection, object-oriented programming, partial revelation and encapsulation of unsafe code. The design goal of Modula-3 was a language that implements the most important features of modern imperative languages in quite basic forms. Thus dangerous and complicating features like multiple inheritance and operator overloading were omitted.

The Modula-3 project started in November 1986 when Maurice Wilkes wrote to Niklaus Wirth with some ideas for a new version of Modula. Wilkes had been working at DEC just prior to this point, and had returned to England and joined Olivetti's Research Strategy Board. Wirth had already moved on to Oberon, but had no problems with the Wilkes' team continuing development under the Modula name. The language definition was completed in August 1988, and an updated version in January 1989. Compilers from DEC and Olivetti soon followed, and 3rd party implementations after that.

Exception handling is based on the now-traditional TRY...EXCEPT block system, the only difference being that the EXCEPT construct defined a pseudo-CASE with each possible exception as a case in one EXCEPT clause. Modula-3 also supports a LOOP...EXIT...END construct that loops until an EXIT occurs, a structure equivalent to a simple loop inside of a TRY...EXCEPT clause.

Object support is intentionally kept to its simplest terms. A class is introduced with the OBJECT declaration, which is essentially a RECORD with some specific syntax. For instance:

A = OBJECT a: INTEGER; METHODS p() := AP; END;

Defines a new class "A", which contains a single field "a" and method p. The procedure AP that implements p must be defined elsewhere:

PROCEDURE AP(self: A) = BEGIN ... END;

Method calls are accomplished with o.p();, where o is a variable of type A.

Modula-3's REVEAL construct provides a conceptually simple and clean yet very powerful mechanism for hiding implementation details from clients, with arbitrarily many levels of "friendliness".

Template:List of programming languages