From Wikipedia, the free encyclopedia
  (Redirected from Algol W)
Jump to navigation Jump to search

ParadigmsMulti-paradigm: procedural, imperative, structured
Designed byNiklaus Wirth, Tony Hoare
First appeared1966; 56 years ago (1966)
Typing disciplineStatic, strong
Implementation languagePL360
PlatformIBM System/360
Influenced by
Pascal, Modula-2

ALGOL W is a programming language. It is based on a proposal for ALGOL X by Niklaus Wirth and Tony Hoare as a successor to ALGOL 60. ALGOL W is a relatively simple upgrade of the original ALGOL 60, adding string, bitstring, complex number and reference to record data types and call-by-result passing of parameters, introducing the while statement, replacing switch with the case statement, and generally tightening up the language.

Wirth's entry was considered too little of an advance over ALGOL 60, and the more complex entry from Adriaan van Wijngaarden was selected in a highly contentious meeting. Wirth later published his version as A contribution to the development of ALGOL.[1] With a number of small additions, this eventually became ALGOL W.

Wirth supervised a high quality implementation for the IBM System/360 at Stanford University that was widely distributed.[2] The implementation was written in PL360, an ALGOL-like assembly language designed by Wirth. The implementation includes influential debugging and profiling abilities.

ALGOL W served as the basis for the Pascal language, and the syntax of ALGOL W will be immediately familiar to anyone with Pascal experience. The key differences are improvements to record handling in Pascal, and, oddly, the loss of ALGOL W's ability to define the length of an array at runtime, which is one of Pascal's most-complained-about features.

Syntax and semantics[edit]

ALGOL W's syntax is built on a subset of the EBCDIC character encoding set. In ALGOL 60, reserved words are distinct lexical items, but in ALGOL W they are only sequences of characters, and do not need to be stropped. Reserved words and identifiers are separated by spaces.[2] In these ways ALGOL W's syntax resembles that of Pascal and later languages.

The ALGOL W Language Description[3] defines ALGOL W in an affix grammar that resembles Backus–Naur form (BNF). This formal grammar was a precursor of the Van Wijngaarden grammar.[1][4]

Much of ALGOL W's semantics is defined grammatically:[3]

  • Identifiers are distinguished by their definition within the current scope. For example, a ⟨procedure identifier⟩ is an identifier that has been defined by a procedure declaration, a ⟨label identifier⟩ is an identifier that is being used as a goto label.
  • The types of variables and expressions are represented by affixes. For example ⟨τ function identifier⟩ is the syntactic entity for a function that returns a value of type τ, if an identifier has been declared as an integer function in the current scope then that is expanded to ⟨integer function identifier⟩.
  • Type errors are grammatical errors. For example, ⟨integer expression⟩ / ⟨integer expression⟩ and ⟨real expression⟩ / ⟨real expression⟩ are valid but distinct syntactic entities that represent expressions, but ⟨real expression⟩ DIV ⟨integer expression⟩ (i.e., integer division performed on a floating-point value) is an invalid syntactic entity.


This demonstrates ALGOL W's record type facility.

    STRING(20) NAME; 

        WHILE (P ¬= NULL) AND (¬ MALE(P)) OR (P = FATHER(R)) DO
            P := ELDERSIBLING(P);
        WHILE (M ¬= NULL) AND (¬ MALE(M)) DO
            M := ELDERSIBLING(M);
        IF P = NULL THEN 
        ELSE IF M = NULL THEN 
            IF AGE(P) < AGE(M) THEN P ELSE M


The major part of ALGOL W, amounting to approximately 2,700 cards, was written in Wirth's PL360. An interface module for the IBM operating system (OS) in use (OS, DOS, MTS, ORVYL) was written in IBM assembly language, amounting to fewer than 250 cards. [1]

In an OS environment on a 360/67 with spooled input and output files, the compiler will recompile itself in about 25 seconds. The compiler is approximately 2700 card images. Thus, when the OS scheduler time is subtracted from the execution time given above, it is seen that the compiler runs at a speed in excess of 100 cards per second (for dense code).

In a DOS environment on a 360/30, the compiler is limited only by the speed of the card reader. The compiler has successfully recompiled itself on a 64K 360/30 at a rate of 1200 cards per minute (the speed of the card reader). This is impressive when compared to the time needed for the DOS Assembler to assemble the interface module which consists of under 250 cards. When the macro instructions are expanded, the DOS interface has 972 card images and the Assembler takes 15 minutes for the assembly.


  1. ^ a b Wirth, Niklaus; Hoare, C. A. R. (June 1966). "A contribution to the development of ALGOL". Communications of the ACM. 9: 413–432. Retrieved 7 October 2020 – via Association for Computing Machinery.
  2. ^ a b Bauer, Henry R.; Becker, Sheldon I.; Graham, Susan L.; Forsythe, George E.; Satterthwaite, Edwin H. (March 1968). Technical Report Number: CS-TR-68-89. Computer Science Department (Report). Stanford University. (Various documents for Stanford's 1972 implementation of ALGOL W; this report includes the ALGOL W Language Description.
  3. ^ a b Bauer, Henry R.; Becker, Sheldon I.; Graham, Susan L.; Satterthwaite, Edwin H.; Sites, Richard L. (June 1972). ALGOL W Language Description (PDF) (Report). Archived from the original (PDF) on 19 November 2012.
  4. ^ van Wijngaarden, Adriaan (22 October 1965). Orthogonal Design and Description of a Formal Language: MR76 (PDF) (Report). Amsterdam, Netherlands: Mathematical Centre. Archived from the original (PDF) on 29 October 2019. Retrieved 7 October 2020 – via Ernst-Abbe-Hochschule Jena, University of Applied Sciences, Germany.

External links[edit]