Category:ALGOL 68
This programming language may be used to instruct a computer to perform a task.
Parameter passing methods:  By reference, By value 

Type safety:  Safe 
Type strength:  Strong 
Type compatibility:  Structural 
Type expression:  Explicit 
Type checking:  Dynamic, Static 
Lang tag(s):  algol68 
See Also: 
ALGOL 68 (short for ALGOrithmic Language 1968) is an imperative computer 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.
The main aims and principles of design of ALGOL 68:
 Completeness and clarity of design,
 Orthogonal design,
 Security,
 Efficiency:
 Static mode checking,
 Modeindependent parsing,
 Independent compilation,
 Loop optimization,
 Representations  in minimal & larger character sets.
Execute an ALGOL 68 program online[edit]
Grammar[edit]
The formal definition of Algol 68 is given by a "TwoLevel" or "Van Wijngaarden" grammar.
This specifies much more than "just" the syntax and includes such semantic details as the requirement of identifiers to be declared, the necessary type checking and coercions to be applied, etc. The degree of precision allowed by the grammar came at the cost of increased complexity relative to Backus Naur Form, which was used to define ALGOL 60. It is recomended that less formal material (such as the books mentioned under "Resources" below) be consulted before delving into the Revised Report.
A syntax chart is available here
Resources[edit]
 ALGOL BULLETIN  March 1959 to August 1988, in 52 issues
 Algol68 mailinglist  December 2008  algol68user AT lists.sourceforge.net
 Algol68 group at linkedin  includes various famous compiler composers.
Books available online:
 Algol 68G Manual  By Marcel van der Veer Includes the Revised Report
 Programming Algol 68 Made Easy  by Sian Mountbatten (on softwarepreservation.org)
 Informal Introduction to Algol 68  by C. H. Lindsey & S. V. Van der Meulen (on softwarepreservation.org)  if you prefer (and find) a hardcopy, be sure to get the 1977 edition. Highly recomended!
Editor modes:
 Emacs mode for Algol 68 supporting syntax highlighting and contextsensitive indentation.
 Vim script providing support for syntax highlighting.
 GeSHi syntax highlighting
 VSCode Algol 68 syntax highlighting
Status[edit]
 20th December 1968  ALGOL 68's Final Report was ratified by UNESCO's IFIP working group 2.1 in Munich.
 20th December 2008  Zig Zag  the 100th ALGOL 68 code contribution on rosettacode.org!
 Happy 40th Birthday ALGOL 68,
 AND 50th Birthday ALGOL 58.
 23rd August 2009  algol68g1.18.09h released
 20th December 2009  Happy 51st/41st Birthdays with Hamming numbers  the 200th ALGOL 68 code contribution on rosettacode.org!
 This time code was by Marcel van der Veer, author of Algol 68 Genie
 25th October 2011  Jejones3141 added Soundex  the 300th ALGOL 68 code specimen.
Revisions[edit]
 Mar. 1968: Draft Report on the Algorithmic Language ALGOL 68  Edited by: A. van Wijngaarden, B.J. Mailloux, J.E.L. Peck and C.H.A. Koster.
 Oct. 1968: Penultimate Draft Report on the Algorithmic Language ALGOL 68  Chapters 19  Edited by: A. van Wijngaarden, B.J. Mailloux, J.E.L. Peck and C.H.A. Koster.
 Dec. 1968: Report on the Algorithmic Language ALGOL 68  Offprint from Numerische Mathematik, 14, 79218 (1969); SpringerVerlag.  Edited by: A. van Wijngaarden, B.J. Mailloux, J.E.L. Peck and C.H.A. Koster.
 Sep 1973: Revised Report on the Algorithmic Language Algol 68  SpringerVerlag 1976  Edited by: A. van Wijngaarden, B.J. Mailloux, J.E.L. Peck, C.H.A. Koster, M. Sintzoff, C.H. Lindsey, L.G.L.T. Meertens and R.G. Fisker.
Coding style of samples[edit]
Click "Expand" for more details.
Many of the code samples provided here have a leading main:(
and a matching )
at the end. These are not actually required in the language, but are included so as to highlight the main routine.
On some compilers, it may be necessary to include appropriate "job cards" or preludes in order for the programs to compile successfully. Hopefully not too much else is required. Examples:
Brief Algol68  Algol68 as in rosettacode  Actual ELLA Algol 68RS code 
print(("Hello, world!",new line)) 
main:( print(("Hello, world!",new line)) ) 
PROGRAM helloworld CONTEXT VOID USE standard BEGIN print(("Hello, world!", new line)) END FINISH 
Examples of different program representations
At the time when ALGOL 68 was defined some predominant computers had
24 or 36 bit words, with 6 bit character sets. Hence it was desirable that
ALGOL 68 should be able to run on machines with only uppercase.
The official spec provided for different representations of the same
program. Quote stropping (enclosing the bold words in single quotes)
and Point stropping (preceeding the bold words with a dot)
were used. A variant of Point stropping called RES stropping was also defined.
In RES stropping some languagedefined bold words are not preceded by a dot.
A pragmatic comment may have been required to indicate which
stropping convention was to be used, as in some of the examples below.
Upper stropping (representing the bold words by upper case and
nonbold words in lower case) was introduced by Algol 68R. Upper stropping
is used by Algol 68RS and is one of the options for Algol 68G.
Rutgers ALGOL 68 uses quote stropping. Most of the samples
on Rosetta Code use Upper stropping.
Example:
Algol68 as typically published
¢ bold/underline typeface ¢ mode xint = int; xint sum sq:=0; for i while sum sq≠70×70 do sum sq+:=i↑2 od 
quote stropping (similar to wiki)
'pr' quote 'pr' 'mode' 'xint' = 'int'; 'xint' sum sq:=0; 'for' i 'while' sum sq≠70×70 'do' sum sq+:=i↑2 'od' 
7bit/ascii compiler
.PR UPPER .PR MODE XINT = INT; XINT sum sq:=0; FOR i WHILE sum sq/=70*70 DO sum sq+:=i**2 OD 
6bits/byte compiler
.PR POINT .PR .MODE .XINT = .INT; .XINT SUM SQ:=0; .FOR I .WHILE SUM SQ .NE 70*70 .DO SUM SQ .PLUSAB I .UP 2 .OD 
RES stropping
.PR RES .PR mode .xint = int; .xint sum sq:=0; for i while sum sq≠70×70 do sum sq+:=i↑2 od 
Upper stropping
# upper case = bold # MODE XINT = INT; XINT sum sq:=0; FOR i WHILE sum sq /= 70*70 DO sum sq PLUSAB i UP 2 OD 
Coercion (casting)[edit]
ALGOL 68 has a hierarchy of contexts which determine which kind of coercions are available at a particular point in the program.
Click "Expand" for more details.
These contexts are:
N a 
Context location  Coercions available in this context  Coercion examples  

Soft  Weak  Meek  Firm  Strong  
S t 
Right hand side of:
Also:

deproc eduring  all soft then weak deref erencing  all weak then deref erencing  all meek then uniting  all firm then widening, rowing and voiding 
Widening occurs if there is no loss of precision. For example: An INT will be coerced to a REAL, and a REAL will be coerced to a LONG REAL. But not viceversa. Examples: <lang algol68>INT to LONG INT INT to REAL REAL to COMPL BITS to []BOOL BYTES to STRING</lang> A variable can also be coerced (rowed) to an array of length 1. For example: <lang algol68>INT to [1]INT REAL to [1]REAL</lang> etc 
F i 

Example:
<lang algol68>UNION(INT,REAL) var := 1</lang>  
M e 
<lang algol68>IF ~ THEN ... FI</lang> and <lang algol68>FROM ~ BY ~ TO ~ WHILE ~ DO ... OD etc</lang>

Examples:
<lang algol68>REF REF BOOL to BOOL REF REF REF INT to INT</lang>  
W e 

Examples:
<lang algol68>REF BOOL to REF BOOL REF REF INT to REF INT REF REF REF REAL to REF REAL REF REF REF REF STRUCT to REF STRUCT</lang>  
S o 
The LHS of assignments, as "~" in: <lang algol68>~ := ...</lang>  Example:

For more details about Primaries and Secondaries refer to Operator precedence.
See also[edit]
Library code used in Rosetta Code samples[edit]
Subcategories
This category has the following 3 subcategories, out of 3 total.
@
 ALGOL 68 Implementations (9 P)
 ALGOL 68 User (7 P)
Pages in category "ALGOL 68"
The following 200 pages are in this category, out of 865 total.
(previous page) (next page)E
 Egyptian division
 Egyptian fractions
 Elementwise operations
 Elementary cellular automaton
 Emirp primes
 Empty directory
 Empty program
 Empty string
 Enforced immutability
 Entropy
 Entropy/Narcissist
 Enumerations
 Environment variables
 Equilibrium index
 ErdősNicolas numbers
 Erdősprimes
 Esthetic numbers
 Ethiopian multiplication
 EuclidMullin sequence
 Euler method
 Euler's identity
 Euler's sum of powers conjecture
 Evaluate binomial coefficients
 Even numbers which cannot be expressed as the sum of two twin primes
 Even or odd
 Evolutionary algorithm
 Exactly three adjacent 3 in lists
 Exceptions
 Exceptions/Catch an exception thrown in a nested call
 Execute a system command
 Execute Brain****
 Execute Computer/Zero
 Execute HQ9+
 Execute SNUSP
 Exponentiation operator
 Exponentiation order
 Exponentiation with infix operators in (or operating on) the base
 Extend your language
 Extract file extension
F
 Factorial
 Factorial primes
 Factorions
 Factors of a Mersenne number
 Factors of an integer
 Farey sequence
 Fast Fourier transform
 Feigenbaum constant calculation
 Fermat pseudoprimes
 Fibonacci nstep number sequences
 Fibonacci sequence
 Fibonacci word
 File extension is in extensions list
 File input/output
 File modification time
 File size
 Filter
 Find adjacent primes which differ by a square integer
 Find common directory path
 Find first and last set bit of a long integer
 Find first missing positive
 Find if a point is within a triangle
 Find limit of recursion
 Find prime numbers of the form n*n*n+2
 Find square difference
 Find squares n where n+1 is prime
 Find the intersection of two lines
 Find the last Sunday of each month
 Find the missing permutation
 Find words which contain the most consonants
 Find words which contains all the vowels
 Find words which contains more than 3 e vowels
 Find words whose first and last three letters are equal
 Find words with alternating vowels and consonants
 First 9 prime Fibonacci number
 First power of 2 that has leading decimal digits of 12
 Firstclass functions
 Firstclass functions/Use numbers analogously
 Five weekends
 Fivenum
 FizzBuzz
 Flatten a list
 Flowcontrol structures
 Floyd's triangle
 Forest fire
 Fork
 Formatted numeric output
 Forward difference
 Four sides of square
 Fractran
 Frobenius numbers
 Function composition
 Function definition
 Function prototype
 Fusc sequence
G
 Gamma function
 Gapful numbers
 GaussJordan matrix inversion
 Gaussian elimination
 Gaussian primes
 General FizzBuzz
 Generalised floating point addition
 Generalised floating point multiplication
 Generate lower case ASCII alphabet
 Generate random numbers without repeating a value
 Generator/Exponential
 Generic swap
 Goldbach's comet
 Gradient descent
 Gray code
 Greatest common divisor
 Greatest element of a list
 Greatest subsequential sum
 Guess the number
 Guess the number/With feedback
 Guess the number/With feedback (player)
H
 Hailstone sequence
 Halt and catch fire
 Hamming numbers
 Happy numbers
 Harmonic series
 Harshad or Niven series
 Haversine formula
 Hello world/Graphical
 Hello world/Line printer
 Hello world/Newbie
 Hello world/Newline omission
 Hello world/Standard error
 Hello world/Text
 Here document
 Heronian triangles
 Hex words
 Hickerson series of almost integers
 Higherorder functions
 Hilbert curve
 Hofstadter Q sequence
 HofstadterConway $10,000 sequence
 Holidays related to Easter
 Honaker primes
 Horizontal sundial calculations
 Horner's rule for polynomial evaluation
 Host introspection
 Hostname
 HTTP
 Humble numbers
I
 I before E except after C
 Identity matrix
 Idiomatically determine all the lowercase and uppercase letters
 Idoneal numbers
 Implicit type conversion
 Include a file
 Inconsummate numbers in base 10
 Increasing gaps between consecutive Niven numbers
 Increment a numerical string
 Infinity
 Input loop
 Input/Output for lines of text
 Input/Output for pairs of numbers
 Integer comparison
 Integer overflow
 Integer sequence
 Intersecting number wheels
 Introspection
 Inverted syntax
 ISBN13 check digit
 Isograms and heterograms
 Isqrt (integer square root) of X
 Iterated digits squaring
J
K
L
 Lah numbers
 Langton's ant
 Largest difference between adjacent primes
 Largest five adjacent number
 Largest int from concatenated ints
 Largest number divisible by its digits
 Largest palindrome product
 Largest prime factor
 Largest product in a grid
 Largest proper divisor of n
 Last Friday of each month
 Last list item
 Law of cosines  triples
 Leap year
 Least common multiple
 Left factorials
 Leonardo numbers