Science  People  Locations  Timeline
Index: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Home > ALGOL 68


 Contents
ALGOL 68 was conceived as a successor to the ALGOL 60 programming language, designed with the goal of a much wider scope of application and a more rigorously defined syntax and semantics. Long under-recognized (probably due to its mainly European origin), the contributions of ALGOL 68 to the whole field of computer science are deep and wide ranging, although many of them were not publicly identified until they were passed, in one form or another, to many subsequently developed programming languages.

Critics of ALGOL 68 point out that it abandoned the simplicity of ALGOL 60 and became a vehicle for the various complex ideas of its designers. The language also did little to make the compiler writer's task easy, in contrast to its deliberately simple contemporaries (and competitors) C and Pascal.

Today, the different dialects of the ML programming language family, such as OCAML, bear some resemblance to ALGOL 68, while being more advanced. The ALGOL 68 heritage is also acknowledged by Scheme, whose "Revised" (with an exponent) standards echo the "Revised Report" on ALGOL.

For a full length treatment of the language, see Programming Algol 68 Made Easy, a book by Dr. Sian Leitch.

1 Overview

1.1 Block structure

The elemental unit of an ALGOL 68 program is the block (or closed clause):

begin declarations and statements end

where the keywords begin and end may be replaced by ( and ), respectively:

(declarations and statements)

The specific notation for keywords is not specified in ALGOL 68, to allow for different tastes and portability (some common options being to use all uppercase letters BEGIN, underlines begin, dot prefixes .begin, and bold type  begin).

1.2 Declarations

All variables need to be declared, but unlike most modern languages, the declaration does not have to appear prior to the first use. The basic datatypes (called modes in ALGOL 68 parlance) are real, int, compl ( complex number), bool and char. For example:

real pi = 3.1415926; int n = 2;

However, the declaration real pi; is just syntactic sugar for ref real pi = loc real;. That is, pi is really the constant name for a reference to a newly generated local real variable. Furthermore, instead of defining both real and double, or int and long and short, etc., ALGOL 68 provided modifiers, so that the presently common double would be written as long real instead, for example. Type queries of the kind of max real and min long int were provided to adapt programs to different implementations.

1.3 Expressions and compound statements

ALGOL 68 being an expression-oriented programming language, the value returned by an assignment statement is a reference to the destination. Thus, the following is valid ALGOL 68 code:

real twice pi = 2 * real pi = 3.1415926;

This notion is present in C and PerlImage:Programming-republic-of-perl. gif|right|framed|Programming Republic of logo]] Perl also Practical Extraction and Report Language (a backronym, see below), is a programming language released by Larry Wall on December 18, 1987 that borrows features fr, among others. Note that twice pi is a single identifier, i.e., blanks were permitted within ALGOL 68 names (effectively avoiding the underscores versus camel case versus all lowercase issues at once).

As another example, to express the mathematical idea of a sum of f(i) from i=1 to N, the following ALGOL 68 integer expression suffices:

(int sum := 0; for i to N do sum +:= f(i) od; sum)

Note that, being an integer expression, the former block of code can be used in any context where an integer value can be used. A block of code returns the value of the last expression it evaluated; this idea is present in PerlImage:Programming-republic-of-perl. gif|right|framed|Programming Republic of logo]] Perl also Practical Extraction and Report Language (a backronym, see below), is a programming language released by Larry Wall on December 18, 1987 that borrows features fr, among other languages.

Compound statements are all terminated by distinctive (if somewhat irreverent) closing brackets:

if condition then statements [ else statements ] fi [ for index from first [ by inc ] to last ] [ while condition ] do statements od case switch in statements esac

This scheme not only avoids the dangling elseThe dangling else is a well-known problem in computer programming in which a seemingly well-defined grammar can become ambiguous. In many programming languages you can write code like this: if a then if b then s1 else s2 which can be understood in two way problem but also avoids having to use begin and end in embedded statement sequences. Furthermore, the symbol pattern if...then...else...fi may be replaced by the more compact ...|...|... (see example below). The idea of terminating a compound statement with a backwards version of the keyword that started it is continued in the Bourne shellThe Bourne shell or sh was the default Unix shell of Unix Version 7, and replaced the original Unix shell, whose executable file had the same name, sh . It was developed by Stephen Bourne, of AT&T Bell Laboratories, and first released in 1977 in the Versi and its descendants.



Read more »

Non User