ALGOL W - Introduction

As discussed in the previous post, there were discussions on how to extend ALGOL after the experience of implementing ALGOL 60 on different systems. One such proposal was formulated by Niklaus Wirth and C A R Hoare. It did not get approved by the ALGOL committee, who chose what eventually became ALGOL 68 instead, so Wirth developed his proposal at Stanford and released it as ALGOL W.

ALGOL W overview

ALGOL W builds upon ALGOL 60 rather than making sweeping changes: its enhancements include

ALGOL W on MTS

ALGOL W was originally implemented at Stanford in a high level assembly language called PL360, which I will look at later; this was augmented with S/360 assembler support routines at the University of Newcastle, UM and elsewhere to build the MTS compiler *ALGOLW.

It was the most popular of the ALGOL dialects on MTS, used for teaching programming fundamentals to students at several sites, and is well integrated with the operating system. The compiler features both a ‘compile, load and go’ mode suitable for learning the language and a traditional output to object deck option.

Prerequisites

No special installation instructions to get ALGOL W running - just do the standard D6.0 setup as described in this guide and then sign on as a regular user such as ST01.

Compiling using *ALGOLW

For compile, load and go mode just run *ALGOLW and type the desired program in directly. Finish it with $endfile and the system will compile it, print any errors and if OK will execute it once before returning you to the MTS prompt.

For object mode, run *ALGOLW with the command line option par=deck. It will read source from scards (by default *source* ie standard input) and will write object files to spunch (by default the temporary file -awload). The object file can then be $run directly without referencing any library.

Other *ALGOLW compilation parameters are listed in MTS Volume 16.

Hello world - compile, load and go

Here’s a simple program to print “Hello, world!” five times using the compile, load and go model. After I run *algolw I can type a compiler control statement at the = prompt but instead I enter begin, signaling that source code is being entered. *algolw prompts for the remainder of the program with :.

# $run *algolw
= begin

 Compilation begins ...
:    integer I;
:    for I := 1 until 5 do
:        write("Hello, world!");
:end.
:$endfile

 Options (UN022) :- main, debug

 (MAIN)    0.012 seconds to compile,  size 416 bytes


 Execution begins ...


 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!

 0.001 seconds in execution

Hello world - object file

Here I use the two step process of compiling to an object file and then running it. Assume the source code is in file hello.alw.

# $list hello.alw

     1     begin
     2         % Hello World program for ALGOL W %
     3         integer I;
     4         for I := 1 until 5 do
     5         begin
     6              write("Hello, world!");
     7         end
     8     end.

# $run *algolw scards=hello.alw par=deck

 Options (UN022) :- main, debug
 Object program:  "-AWLOAD"

 (MAIN)    0.007 seconds to compile,  size 416 bytes

# $run -awload

 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!

 0.001 seconds in execution

Further information

MTS volume 16 contains a very readable description of the language, the compiler options and how it integrates with MTS.

Wirth’s Turing award lecture, From programming language design to computer construction, puts ALGOL W in context with Wirth’s other work on Pascal and Modula 2.

The original ALGOL W reference manual from the Stanford implementation can be found here.

Comments

comments powered by Disqus