ALGOL 68-R

Last updated
ALGOL 68R
Original author(s) I. F. Currie, Susan G. Bond, J. D. Morrison
Developer(s) Royal Radar Establishment
Initial releaseJuly 20, 1970;51 years ago (1970-07-20)
Written in ALGOL 60 (original)
ALGOL 68-R (latter)
Operating system George 3
Platform ICL 1907F
Size 34 K words
Available inEnglish
Type Compiler, translator
License Freeware
Website sw.ccs.bcs.org/CCs/g3

ALGOL 68-R was the first implementation of the Algorithmic Language ALGOL 68.

Contents

In December 1968, the report on the Algorithmic Language ALGOL 68 was published. On 20–24 July 1970 a working conference was arranged by the International Federation for Information Processing (IFIP) to discuss the problems of implementing the language, [1] a small team from the Royal Radar Establishment (RRE) attended to present their compiler, written by I. F. Currie, Susan G. Bond, [2] and J. D. Morrison. In the face of estimates of up to 100 man-years to implement the language, using multi-pass compilers with up to seven passes, they described how they had already implemented a one-pass compiler which was in production for engineering and scientific uses.

The compiler

The ALGOL 68-R compiler was initially written in a local dialect of ALGOL 60 with extensions for address manipulation and list processing. The parser was written using J. M. Foster's Syntax Improving Device (SID) parser generator.

About 20K of this is program, which we feel is too large.
– Currie [3]

The first version of the compiler occupied 34 K words. It was later rewritten in ALGOL 68-R, [4] taking around 36 K words to compile most programs. [5]

ALGOL 68-R was implemented under the George 3 operating system on an ICL 1907F. The compiler was distributed at no charge by International Computers Limited (ICL) on behalf of the Royal Radar Establishment (RRE).

Restrictions in the language compiled

It is a question of morality. We have a Bible and you are sinning!
Mailloux [6]

To allow one pass compiling, ALGOL 68-R implemented a subset of the language defined in the original report: [7]

  1. Identifiers, modes and operators must be specified before use.
  2. No automatic proceduring
  3. Explicit VOID mode
  4. No formal declarers
  5. No parallel processing
  6. GOTO may not be omitted
  7. Uniting is only valid in strong positions

Many of these restrictions were adopted by the revised report on ALGOL 68.

Specification before use

To allow compiling in one pass ALGOL 68-R insisted that all identifiers were specified (declared) before use.

The standard program:

PROC even = (INT number) BOOL: ( number = 0 | TRUE | odd (ABS (number - 1))); PROC odd = (INT number) BOOL: ( number = 0 | FALSE | even (ABS (number - 1)));

would have to be rewritten as:

PROC (INT) BOOL odd; PROC even = (INT number) BOOL : ( number = 0 | TRUE | odd (ABS (number - 1))); odd := (INT number) BOOL : ( number = 0 | FALSE | even (ABS (number - 1)));

To allow recursive declarations of modes (types) a special stub mode declaration was used to inform the compiler that an up-coming symbol was a mode rather than an operator:

MODEB; MODEA = STRUCT (REFB b); MODEB = [1:10] REFA;

No proceduring

In the standard language the proceduring coercion could, in a strong context, convert an expression of some type into a procedure returning that type. This could be used to implement call by name.

Another case where proceduring was used was the declaration of procedures, in the declaration:

PROC x plus 1 = INT : x + 1;

the right hand side was a cast of x + 1 to integer, which was then converted to procedure returning integer.

The ALGOL 68-R team found this too difficult to handle and made two changes to the language. The proceduring coercion was dropped, and the form mode : expression was redefined as a procedure denotation, casts being indicated by an explicit VAL symbol:

REAL : x     CO a cast to REAL in ALGOL 68 COREALVAL x   CO a cast to REAL in ALGOL 68-R CO

Code that had a valid use for call by name (for example, Jensen's device) could simply pass a procedure denotation:

PROC sum = (INT lo, hi, PROC (INT) REAL term) REAL :  BEGINREAL temp := 0;     FOR i FROM lo TO hi DO        temp +:= term (i);     temp  END;  print (sum (1, 100, (INT i) REAL: 1/i))

In the version of the language defined in the revised report these changes were accepted, although the form of the cast was slightly changed to mode (expression).

REAL (x)      CO a cast to REAL in revised ALGOL 68 CO

Explicit void mode

In the original language the VOID mode was represented by an empty mode:

: x := 3.14;            CO cast (x := 3.14) to void COPROC endit = GOTO end;  CO a procedure returning void CO

The ALGOL 68-R team decided to use an explicit VOID symbol in order to simplify parsing (and increase readability):

VOIDVAL x := 3.14;            CO cast (x := 3.14) to void COPROC endit = VOID : GOTO end;  CO a procedure returning void CO

This modification to the language was adopted by the ALGOL 68 revised report.

No formal declarers

Formal declarers are the modes on the left hand side of an identity declaration, or the modes specified in a procedure declaration. In the original language, they could include array bounds and specified whether the matching actual declarer was fixed, FLEX or EITHER:

[ 15 ] INT a;                    CO an actual declarer, bounds 1:15 COREF [ 3 : ] INT b = a;           CO This is an error COPROC x = (REF [ 1 : EITHER] INT a) : ...

I think it was a reasonable thing myself to omit the bounds from the formal-declarers but I think it was a terrible crime to omit the EITHER or the FLEX
Lindsey [8]

The ALGOL 68-R team redefined formal declarers to be the same as virtual declarers which include no bound information. They found that this reduced the ambiguities in parsing the language and felt that it was not a feature that would be used in working programs.

If a procedure needed certain bounds for its arguments it could check them itself with the UPB (upper bound) and LWB (lower bound) operators.

In ALGOL 68-R the example above could be recoded like this: (the bounds of a in the procedure would depend on the caller).

[ 15 ] INT a;                    CO an actual declarer, bounds 1:15 COREF [] INT b = a [ AT 3];        CO use slice so b has bounds 3:17 COPROC x = (REF [] INT a) VOID: ...   CO bounds given by caller CO

In the revised report on ALGOL 68 formal bounds were also removed, but the FLEX indication was moved in position so it could be include in formal declarers:

[ 1: FLEX ] INT a;      CO original ALGOL 68, or ALGOL 68-R COFLEX [ 1: ] INT a;      CO revised ALGOL 68, CO
PROC x = (REF [ 1: FLEX ] INT a) : ...  CO Original ALGOL 68 COPROC x = (REF [ ] INT a) VOID: ...      CO ALGOL 68-R COPROC x = (REFFLEX [ ] INT a) VOID: ... CO Revised ALGOL 68 CO

No parallel processing

In ALGOL 68 code can be run in parallel by writing PAR followed by a collateral clause, for example in:

PARBEGIN    producer,    consumer END

the procedures producer and consumer will be run in parallel. A semaphore type (SEMA) with the traditional P (DOWN) and V (UP) operators is provided for sysynchronizing between the parts of the parallel clause,

This feature was not implemented in ALGOL 68-R.

An extension named ALGOL 68-RT was written which used the subprogramming feature of the ICL 1900 to provide multithreading facilities to ALGOL 68-R programs with semantics similar to modern thread libraries. [9] No changes were made to the compiler, only the runtime library and the linker.

goto may not be omitted

In ALGOL 68 the GOTO symbol could be omitted from a jump:

PROC stop = : ...;  ...  BEGINIF x > 3 THEN stop FI;  CO a jump, not a call CO    ... stop:    SKIPEND

As ALGOL 68-R was a one pass compiler this was too difficult, so the GOTO symbol was made obligatory.

The same restriction was made in the official sublanguage, ALGOL 68S. [10]

Uniting is only allowed in strong positions

In ALGOL 68 uniting is the coercion that produces a UNION from a constituent mode, for example:

MODEIBOOL = UNION (INT, BOOL);    CO an IBOOL is an INT or a BOOLCOIBOOL a = TRUE;       CO the BOOL value TRUE is united to an IBOOLCO

In standard ALGOL 68 uniting was possible in firm or strong contexts, so for example could be applied to the operands of formulas:

OPISTRUE = (IBOOL a) BOOL: ...;  IFISTRUE 1               CO legal because 1 (INT) can be united to IBOOLCOTHEN ...

The ALGOL 68-R implementers found this gave too many ambiguous situations so restricted the uniting coercion to strong contexts.

The effects of this restriction were rarely important and, if necessary, could be worked around by using a cast to provide a strong context at the required point in the program.

F00L

The ALGOL 68-R compiler initialised unused memory to the value -6815700. [11] [12]

This value was chosen because:

The same value was used to represent NIL.

Stropping

I notice, in some of your sample programs, that you are not underlining or stropping anything.
Mailloux [13]

In ALGOL family languages, it is necessary to distinguish between identifiers and basic symbols of the language. In printed texts this was usually accomplished by printing basic symbols in boldface or underlined (BEGIN or begin for example).

In source code programs, some stropping technique had to be used. In many ALGOL like languages, before ALGOL 68-R, this was accomplished by enclosing basic symbols in single quote characters ('begin' for example). In 68-R, basic symbols could be distinguished by writing them in upper case, lower case being used for identifiers.

As ALGOL 68-R was implemented on a machine with 6-bit bytes (and hence a 64 character set) this was quite complex and, at least initially, programs had to be composed on paper punched tape using a Friden Flexowriter.

Partly based on the experience of ALGOL 68-R, the revised report on ALGOL 68 specified hardware representations for the language, including UPPER stropping.

Extensions to ALGOL 68

ALGOL 68-R included extensions for separate compiling and low-level access to the machine.

Separate compiling

Since ALGOL 68 is a strongly typed language, the simple library facilities used by other languages on the ICL 1900 system were insufficient. ALGOL 68-R was delivered with its own library format and utilities which allowed sharing of modes, functions, variables, and operators between separately compiled segments of code which could be stored in albums. [14]

A segment to be made available to other segments would end with a list of declarations to be made available:

graphlib             CO the segment name COBEGINMODEGRAPHDATA = STRUCT ( ... );    MODEGRAPH = REFGRAPHDATA;    PROC new graph = ( ... ) GRAPH : ...;    PROC draw graph = (GRAPH g) VOID : ...;    ... ENDKEEPGRAPH, new graph, draw graph FINISH

And then the graph functions could be used by another segment:

myprog WITH graphlib FROM graphalbum BEGINGRAPH g = new graph (...);     ...     draw graph (g);     ... ENDFINISH

Low level system access

As a strongly typed high level language, ALGOL 68 prevents programs from directly accessing the low level hardware. No operators exist for address arithmetic, for example.

Since ALGOL 68-R didn't compile to standard ICL semicompiled (link-ready) format, it was necessary to extend the language to provide features in ALGOL 68-R to write code that would normally be written in assembly language. Machine instructions could be written inline, inside CODE ... EDOC sections and the address manipulation operators INC, DEC, DIF, AS were added. [15]

An example, using a George peri operation to issue a command:

[1 : 120] CHAR buff; INT unitnumber; STRUCT (BITS typemode, reply, INT count, REFCHAR address)       control area := (8r47400014,0,120,buff[1]); ...; CODE 0,6/unitnumber; 157,6/typemode OF control area EDOC

Availability

A copy of the ALGOL 68-R compiler, runnable under the George 3 operating system emulator, by David Holdsworth (University of Leeds), is available, with source code, under a GNU General Public License (GPL). [16]

Related Research Articles

ALGOL Family of programming languages

ALGOL is a family of imperative computer programming languages originally developed in 1958. ALGOL heavily influenced many other languages and was the standard method for algorithm description used by the Association for Computing Machinery (ACM) in textbooks and academic sources for more than thirty years.

C (programming language) General-purpose programming language

C is a general-purpose computer programming language. It was created in the 1970s by Dennis Ritchie, and remains very widely used and influential. By design, C's features cleanly reflect the capabilities of the targeted CPUs. It has found lasting use in operating systems, device drivers, protocol stacks, though decreasingly for application software, and is common in computer architectures that range from the largest supercomputers to the smallest microcontrollers and embedded systems.

Pascal (programming language) Programming language

Pascal is an imperative and procedural programming language, designed by Niklaus Wirth as a small, efficient language intended to encourage good programming practices using structured programming and data structuring. It is named in honour of the French mathematician, philosopher and physicist Blaise Pascal.

In computer programming, bounds checking is any method of detecting whether a variable is within some bounds before it is used. It is usually used to ensure that a number fits into a given type, or that a variable being used as an array index is within the bounds of the array. A failed bounds check usually results in the generation of some sort of exception signal.

In computer programming, a function object is a construct allowing an object to be invoked or called as if it were an ordinary function, usually with the same syntax. Function objects are often called functors.

ALGOL 60 is a member of the ALGOL family of computer programming languages. It followed on from ALGOL 58 which had introduced code blocks and the begin and end pairs for delimiting them, representing a key advance in the rise of structured programming. ALGOL 60 was the first language implementing nested function definitions with lexical scope. It gave rise to many other programming languages, including CPL, Simula, BCPL, B, Pascal, and C. Practically every computer of the era had a systems programming language based on ALGOL 60 concepts.

ALGOL 68 Programming language

ALGOL 68 is an imperative programming language that was conceived as a successor to the ALGOL 60 programming language, designed with the goal of a much wider scope of application and more rigorously defined syntax and semantics.

In compiler construction, name mangling is a technique used to solve various problems caused by the need to resolve unique names for programming entities in many modern programming languages.

A struct in the C programming language is a composite data type declaration that defines a physically grouped list of variables under one name in a block of memory, allowing the different variables to be accessed via a single pointer or by the struct declared name which returns the same address. The struct data type can contain other data types so is used for mixed-data-type records such as a hard-drive directory entry, or other mixed-type records.

In computer science, a Van Wijngaarden grammar is a two-level grammar which provides a technique to define potentially infinite context-free grammars in a finite number of rules. The formalism was invented by Adriaan van Wijngaarden to define rigorously some syntactic restrictions which previously had to be formulated in natural language, despite their essentially syntactical content.

ALGOL 68C is an imperative computer programming language, a dialect of ALGOL 68, that was developed by Stephen R. Bourne and Michael Guy to program the Cambridge Algebra System (CAMAL). The initial compiler was written in the Princeton Syntax Compiler that was implemented by J. H. Mathewman at Cambridge.

The computer programming languages C and Pascal have similar times of origin, influences, and purposes. Both were used to design their own compilers early in their lifetimes. The original Pascal definition appeared in 1969 and a first compiler in 1970. The first version of C appeared in 1972.

The C and C++ programming languages are closely related but have many significant differences. C++ began as a fork of an early, pre-standardized C, and was designed to be mostly source-and-link compatible with C compilers of the time. Due to this, development tools for the two languages are often integrated into a single product, with the programmer able to specify C or C++ as their source language.

S-algol is a computer programming language derivative of ALGOL 60 developed at the University of St Andrews in 1979 by Ron Morrison and Tony Davie. The language is a modification of ALGOL to contain orthogonal data types that Morrison created for his PhD thesis. Morrison would go on to become professor at the university and head of the department of computer science. The S-algol language was used for teaching at the university at an undergraduate level until 1999. It was also the language taught for several years in the 1980s at a local school in St. Andrews, Madras College. The computer science text Recursive Descent Compiling describes a recursive descent compiler for S-algol, implemented in S-algol.

C++ doesn't have:

The Interactive ALGOL 68 compiler for ALGOL 68 was made available by Peter Craven of Algol Applications from 1984. Then in 1994 from OCCL until 2004.

ALGOL 68RS is the second ALGOL 68 compiler written by I. F. Currie and J. D. Morrison, at the Royal Signals and Radar Establishment (RSRE). Unlike the earlier ALGOL 68-R, it was designed to be portable, and implemented the language of the Revised Report.

S3 is a structured, imperative high-level computer programming language. It was developed by the UK company International Computers Limited (ICL) for its 2900 Series mainframes. It is a system programming language with syntax influenced by ALGOL 68 but with data types and operators aligned to those offered by the 2900 Series. It was the implementation language of the operating system VME.

In computer programming, a variable-length array (VLA), also called variable-sized or runtime-sized, is an array data structure whose length is determined at run time . In C, the VLA is said to have a variably modified type that depends on a value.

RTL/2 is a discontinued high-level programming language for use in real-time computing, developed at Imperial Chemical Industries, Ltd. (ICI), by J.G.P. Barnes. It was originally used internally in ICI but was distributed by SPL International in 1974. It was based on concepts from ALGOL 68, and intended to be small and simple. RTL/2 was standardised in 1980 by the British Standards Institution.

References

  1. Peck, J.E.L., ed. (1970), Proceedings of the IFIP working conference on ALGOL 68 Implementation, Munich: North-Holland, ISBN   0-7204-2045-8
  2. Bond, Susan; Abbate, Janet (26 September 2001). "Oral-History: Susan Bond: Developing the World's First ALGOL 68 Compiler". Engineering and Technology History Wiki (ETHW). Institute of Electrical and Electronics Engineers (IEEE). Retrieved 22 April 2020 via United Engineering Foundation (UEF).
  3. ALGOL 68 implementation, page 21
  4. Currie, I. F.; Bond, S. G.; Morison, J. D. (1971), "ALGOL 68-R, Its Implementation and Use", Proc IFIP Congress 1971 (Information Processing 1971), Ljubljana, Yugoslavia: North-Holland, pp. 360–363, ISBN   0-7204-2063-6
  5. Anonymous (January 1977). Algol 68-R System – Installation and Maintenance (PDF). Division of Computing and Software Research - Royal Radar Establishment. Retrieved 2011-04-09.[ permanent dead link ]
  6. ALGOL 68 implementation, page 294
  7. ALGOL 68 implementation, pages 21-26
  8. ALGOL 68 implementation, page 276
  9. Oliver, J. R.; Newton, R.S. (1979). "Practical experience with ALGOL 68-RT". The Computer Journal. 22 (2): 114–118. doi: 10.1093/comjnl/22.2.114 .
  10. Lindsey, Charles H.; van der Meulen, S. G. (1997). "Appendix 4, the sublanguage". informal introduction to ALGOL 68 (revised). north-holland. ISBN   0-7204-0726-5.
  11. Raymond, Eric S. (1996). "fool". The new hacker's dictionary; 3rd edition. MIT Press. p. 200. ISBN   978-0-262-68092-9. The Algol 68-R compiler used to initialize its storage to the character string "F00LF00LF00LF00L..." because as a pointer or as a floating point number it caused a crash, and as an integer or a character string it was very recognizable in a dump.
  12. Algol 68-R System - Installation and Maintenance, page 25
  13. ALGOL 68 implementation, page 30
  14. Woodward, P. M.; Bond, S. G. (1974). "14 - Program segmentation". ALGOL 68-R Users Guide. Her Majesty's Stationery Office (HMSO). pp. 87–89. ISBN   0-11-771600-6.
  15. Algol 68-R System - Installation and Maintenance, pp 26-30
  16. Toal, Graham (September 2018). "George3: Emulation of the ICL 1900". Software Preservation and Machine Emulation. Retrieved 2020-04-19.