| ALGOL 68R | |
|---|---|
| Original authors | I. F. Currie,Susan G. Bond, J. D. Morrison |
| Developer | Royal Radar Establishment |
| Initial release | July 20, 1970; 55 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 in | English |
| Type | Compiler,translator |
| License | Freeware |
| Website | sw |
ALGOL 68-R was the first implementation of the Algorithmic LanguageALGOL 68.
In December 1968, the report on the Algorithmic Language ALGOL 68 was published. On 20–24 July 1970 a working conference was arranged by theInternational Federation for Information Processing (IFIP) to discuss the problems of implementing the language,[1] a small team from theRoyal Radar Establishment (RRE) attended to present theircompiler, 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, usingmulti-pass compilers with up to seven passes, they described how they had already implemented aone-pass compiler which was in production for engineering and scientific uses.
The ALGOL 68-R compiler was initially written in a local dialect ofALGOL 60 with extensions for address manipulation and list processing. The parser was written using J. M. Foster'sSyntax 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 theGeorge 3 operating system on anICL 1907F. The compiler was distributed at no charge byInternational Computers Limited (ICL) on behalf of theRoyal Radar Establishment (RRE).
To allow one pass compiling, ALGOL 68-R implemented a subset of the language defined in the original report:[7]
Many of these restrictions were adopted by the revised report on ALGOL 68.
To allow compiling in one pass ALGOL 68-R insisted that all identifiers werespecified (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 ofmodes (types) a specialstub 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;
In the standard language theproceduringcoercion could, in astrong context, convert an expression of some type into a procedure returning that type. This could be used to implementcall 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 acast ofx + 1 to integer, which was then converted toprocedure 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 formmode : expression was redefined as aprocedure denotation, casts being indicated by an explicitVAL symbol:
REAL : xCO a cast toREAL in ALGOL 68COREALVAL xCO a cast toREAL in ALGOL 68-RCO
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 iFROM loTO hiDO temp +:= term (i); tempEND; 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 tomode (expression).
REAL (x)CO a cast toREAL in revised ALGOL 68CO
In the original language theVOID mode was represented by an empty mode:
: x := 3.14;CO cast (x := 3.14) to voidCOPROC endit =GOTO end;CO a procedure returning voidCO
The ALGOL 68-R team decided to use an explicitVOID symbol in order to simplify parsing (and increase readability):
VOIDVAL x := 3.14;CO cast (x := 3.14) to voidCOPROC endit =VOID :GOTO end;CO a procedure returning voidCO
This modification to the language was adopted by the ALGOL 68 revised report.
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 matchingactual declarer was fixed,FLEX orEITHER:
[ 15 ]INT a;CO an actual declarer, bounds 1:15COREF [ 3 : ]INT b = a;CO This is an errorCOPROC 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 theEITHER or theFLEX
–Lindsey[8]
The ALGOL 68-R team redefined formal declarers to be the same asvirtual 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 theUPB (upper bound) andLWB (lower bound) operators.
In ALGOL 68-R the example above could be recoded like this: (the bounds ofa in the procedure would depend on the caller).
[ 15 ]INT a;CO an actual declarer, bounds 1:15COREF []INT b = a [AT 3];CO useslice so b has bounds 3:17COPROC x = (REF []INT a)VOID: ...CO bounds given by callerCO
In the revised report on ALGOL 68 formal bounds were also removed, but theFLEX indication was moved in position so it could be include in formal declarers:
[ 1:FLEX ]INT a;CO original ALGOL 68, or ALGOL 68-RCOFLEX [ 1: ]INT a;CO revised ALGOL 68,CO
PROC x = (REF [ 1:FLEX ]INT a) : ...CO Original ALGOL 68COPROC x = (REF [ ]INT a)VOID: ...CO ALGOL 68-RCOPROC x = (REFFLEX [ ]INT a)VOID: ...CO Revised ALGOL 68CO
In ALGOL 68 code can be run in parallel by writingPAR followed by acollateral clause, for example in:
PARBEGIN producer, consumerEND
the proceduresproducer andconsumer will be run in parallel. Asemaphore type (SEMA) with the traditionalP (DOWN) andV (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 thesubprogramming feature of theICL 1900 to provide multithreading facilities to ALGOL 68-R programs with semantics similar to modernthread libraries.[9] No changes were made to the compiler, only theruntime library and the linker.
In ALGOL 68 theGOTO symbol could be omitted from a jump:
PROC stop = : ...;...BEGINIF x > 3THEN stopFI;CO a jump, not a callCO ...stop:SKIPEND
As ALGOL 68-R was a one pass compiler this was too difficult, so theGOTO symbol was made obligatory.
The same restriction was made in the official sublanguage,ALGOL 68S.[10]
In ALGOL 68uniting is the coercion that produces aUNION from a constituent mode, for example:
MODEIBOOL =UNION (INT,BOOL);CO anIBOOL is anINT or aBOOLCOIBOOL a =TRUE;CO theBOOL valueTRUE isunited to anIBOOLCO
In standard ALGOL 68 uniting was possible infirm orstrong contexts, so for example could be applied to the operands offormulas:
OPISTRUE = (IBOOL a)BOOL: ...;IFISTRUE 1CO legal because 1 (INT) can be united toIBOOLCOTHEN ...
The ALGOL 68-R implementers found this gave too many ambiguous situations so restricted the uniting coercion tostrong contexts.
The effects of this restriction were rarely important and, if necessary, could be worked around by using acast to provide a strong context at the required point in the program.
The ALGOL 68-R compiler initialised unused memory to the value -6815700.[11][12]
This value was chosen because:
F00LThe same value was used to representNIL.
I notice, in some of your sample programs, that you are not underlining or stropping anything.
–Mailloux[13]
InALGOL 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 orbegin for example).
Insource code programs, somestropping 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-bitbytes (and hence a 64 character set) this was quite complex and, at least initially, programs had to be composed on paperpunched tape using aFriden 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.
ALGOL 68-R included extensions forseparate compiling and low-level access to the machine.
Since ALGOL 68 is astrongly 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 compiledsegments of code which could be stored inalbums.[14]
A segment to be made available to other segments would end with a list of declarations to be made available:
graphlibCO the segment nameCOBEGINMODEGRAPHDATA =STRUCT ( ... );MODEGRAPH =REFGRAPHDATA;PROC new graph = ( ... )GRAPH : ...;PROC draw graph = (GRAPH g)VOID : ...; ...ENDKEEPGRAPH, new graph, draw graphFINISH
And then the graph functions could be used by another segment:
myprogWITH graphlibFROM graphalbumBEGINGRAPH g = new graph (...); ... draw graph (g); ...ENDFINISH
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 ICLsemicompiled (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 inassembly language. Machine instructions could be writteninline, insideCODE ...EDOC sections and the address manipulation operatorsINC,DEC,DIF,AS were added.[15]
An example, using aGeorgeperi 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/typemodeOF control areaEDOC
A copy of the ALGOL 68-R compiler, runnable under theGeorge 3 operating system emulator, by David Holdsworth (University of Leeds), is available, with source code, under aGNU General Public License (GPL).[16]
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.