next up previous contents
Next: Michaelmas Term 1997: Part Up: Long Vacation 1997: Part Previous: Long Vacation 1997: Part

Modula-3 and the Thor Teaching Service

Lecturers: Dr F.H. King and Mr R.J. Stibbs
(fhk1@cl.cam.ac.uk and rjs1@cam.ac.uk)

No. of lectures + practicals: 20 + 3

This course is normally held in the last two weeks of July. In addition to the work specified for the formal practical classes, numerous exercises are set. These are undertaken outside class hours and discussed in later lectures. At the end of the course, the first of the examinable Assessed Exercises is discussed.

Note that Modula-3 runs under Unix and the local version is the Thor Teaching Service. Features of Unix are introduced as they are required during the course but, in the interests of readability, the information below is principally concerned with Modula-3, and references to Unix are sparse.

Introduction.
A practical introduction to programming in Modula-3 using Unix and X-windows. Unix commands. X-windows. Files and directories.

Elements of programming in Modula-3.
Imperative programming. Compiling, linking and running a simple Modula-3 program, m3makefile and m3build. Components of the Modula-3 system, modules and interfaces, libraries and packages. Loops, conditions, simple input and output.

Further Unix, Modula-3 declarations and types.
Simple Unix shell script. Syntax charts and railroad diagrams. Declarations, types, variables, constants and expressions. CARDINAL, INTEGER, REAL, LONGREAL, BOOLEAN, CHAR, TEXT and ordinal types. Arrays. INC, DEC, ORD and VAL.

Procedures and records, more on types.
Procedures: signatures, argument types and modes, results. Procedure invocation: passing parameters by position, by name and by default. Classification of types. Sub-range types. Procedure variables and assignment. Hashing. Introduction to records.

Sorting, sets.
Introduction to sorting. Open arrays. Arrays of records. Recursion. Sets. Unsafe programming. Case study: the Power Problem, an O(log n) algorithm.
Reference types.
The heap, NEW and garbage collection. Pointer manipulation, lists and trees. Bit manipulation via LOOPHOLE.

Exceptions, dynamic types.
Declaration, raising, catching, propagating and handling exceptions, EXIT and RETURN as anonymous exceptions. The SUBARRAY procedure. Open reference types: NULL and REFANY. Dynamic types: TYPECASE, ISTYPE and NARROW.

Interfaces and modules, introduction to objects.
Examples of do-it-yourself interfaces and modules. Coverage of signatures. Further use of m3makefile. Objects: encapsulation, data fields and methods, creation with NEW. Specialising an object by adding fields and overriding methods. Inheritance. Hierarchies of object types. Bank account as an example.

More on objects.
Default data fields and method specification. Adding methods. Child objects in separate modules. Introduction to information hiding. Tree representation of an arithmetic expression. Random number generation, a card shuffling program. Use of BRANDED.

Opaque types, an expression parser.
The purpose of opaque types. The Public OBJECT convention and the <: notation. Concluding case studies: mutual recursion, handling large integers, lexical analysis and syntax analysis of an arithmetic expression.

Recommended books:

Nelson, G. (ed.) (1991). Systems Programming with Modula-3. Prentice-Hall.

Harbison, S.P. (1992). Modula-3. Prentice-Hall.

Sedgewick, R. (1993). Algorithms in Modula-3. Addison-Wesley.


next up previous contents
Next: Michaelmas Term 1997: Part Up: Long Vacation 1997: Part Previous: Long Vacation 1997: Part

Christine Northeast
Sat Sep 27 09:31:14 BST 1997