Category:ALGOL 68: Difference between revisions
(→Library code used in Rosetta Code samples: Added ALGOL 68-rows) |
|||
Line 268:
== Library code used in Rosetta Code samples ==
[https://rosettacode.org/wiki/Category:ALGOL_68-primes Prime related]
[https://rosettacode.org/wiki/Category:ALGOL_68-rows Row (array) related]
{{language programming paradigm|Concurrent}}
|
Revision as of 16:28, 18 December 2021
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 |
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,
- Mode-independent parsing,
- Independent compilation,
- Loop optimization,
- Representations - in minimal & larger character sets.
Execute an ALGOL 68 program online
Grammar
The grammar for ALGOL 68 is officially in the two level, Van Wijngaarden grammar but a subset has been done in the one level Backus–Naur Form:
- Van Wijngaarden grammar: [1]
- Backus–Naur Form/Yacc: [2]
- Syntax Chart (Size 516.6 kB - File type application/pdf)
Resources
- ALGOL BULLETIN - March 1959 to August 1988, in 52 issues[3]
- Algol68 mailinglist - December 2008 - algol68-user AT lists.sourceforge.net[4]
- Algol68 group at linked: [5] - includes various famous compiler composers.
FYI: There are two online manual pages:
Or - if you prefer a hardcopy - you can try and pick up a hard cover manual like "Informal Introduction to Algol 68" - by C. H. Lindsey & S. V. Vander Meulen. Be sure to get the 1977 edition:
- www.amazon.com - Aboout $119
- barnesandnoble.com - about $40
IItA68 is a beautiful book, and makes great "bedtime" reading... Highly recommended!
- NEW: softwarepreservation.org has an on-line IItA68 PDF ready for download.
Editor modes:
- Emacs mode for Algol 68 supporting syntax highlighting and context-sensitive indentation.
- Vim script providing support for syntax highlighting.
- NEW: GeSHi syntax highlighting
Status
- 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 - algol68g-1.18.0-9h 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
- 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 1-9 - 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, 79-218 (1969); Springer-Verlag. - 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 - Springer-Verlag 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.
Code samples
Most 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 that the code sample is complete, and works with (at least) ALGOL 68G unmodified.
On some compilers, it may be necessary to include appropriate "job cards" or precludes 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 |
Example 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 language-defined 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 non-bold 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' |
7-bit/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 |
6-bits/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)
ALGOL 68 has a hierarchy of contexts which determine which kind of coercions are available at a particular point in the program. 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 vice-versa. 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
Library code used in Rosetta Code samples
Subcategories
This category has the following 3 subcategories, out of 3 total.
@
- ALGOL 68 Implementations (9 P)
- ALGOL 68 User (8 P)
Pages in category "ALGOL 68"
The following 200 pages are in this category, out of 1,019 total.
(previous page) (next page)A
- A+B
- Abbreviations, easy
- Abbreviations, simple
- ABC problem
- ABC words
- Abelian sandpile model
- Abelian sandpile model/Identity
- Abundant odd numbers
- Abundant, deficient and perfect number classifications
- Accumulator factory
- Achilles numbers
- Ackermann function
- Additive primes
- Address of a variable
- AKS test for primes
- Align columns
- Aliquot sequence classifications
- Almkvist-Giullera formula for pi
- Almost prime
- Alternade words
- Amb
- Amicable pairs
- Anadromes
- Anagrams
- Anagrams/Deranged anagrams
- Anaprimes
- Angle difference between two bearings
- Angles (geometric), normalization and conversion
- Anonymous recursion
- Anti-primes
- Append numbers at same position in strings
- Apply a callback to an array
- Apply a digital filter (direct form II transposed)
- Approximate equality
- Apéry's constant
- Arbitrary-precision integers (included)
- Arithmetic derivative
- Arithmetic evaluation
- Arithmetic numbers
- Arithmetic-geometric mean
- Arithmetic/Complex
- Arithmetic/Integer
- Arithmetic/Rational
- Array concatenation
- Array length
- Arrays
- Ascending primes
- ASCII control characters
- Assertions
- Associative array/Creation
- Associative array/Iteration
- Associative array/Merging
- Attractive numbers
- Averages/Arithmetic mean
- Averages/Mean angle
- Averages/Mean time of day
- Averages/Median
- Averages/Mode
- Averages/Pythagorean means
- Averages/Root mean square
- Averages/Simple moving average
B
- B-spline
- Babbage problem
- Bacon cipher
- Balanced brackets
- Balanced ternary
- Barnsley fern
- Base 16 numbers needing a to f
- Base64 encode data
- Bell numbers
- Benford's law
- Bernoulli numbers
- Bernstein basis polynomials
- Best shuffle
- Bin given limits
- Binary coded decimal
- Binary digits
- Binary search
- Binary strings
- Binomial transform
- Bioinformatics/base count
- Birthday problem
- Bitmap
- Bitmap/Bresenham's line algorithm
- Bitmap/Bézier curves/Cubic
- Bitmap/Midpoint circle algorithm
- Bitwise IO
- Bitwise operations
- Blum integer
- Boolean values
- Boustrophedon transform
- Box the compass
- Brilliant numbers
- Bulls and cows
- Bulls and cows/Player
C
- Caesar cipher
- Calculating the value of e
- Calendar
- Calendar - for "REAL" programmers
- Calkin-Wilf sequence
- Call a foreign-language function
- Call a function
- Call an object method
- Calmo numbers
- CalmoSoft primes
- Camel case and snake case
- Canonicalize CIDR
- Cantor set
- Carmichael 3 strong pseudoprimes
- Cartesian product of two or more lists
- Case-sensitivity of identifiers
- Casting out nines
- Catalan numbers
- Catalan numbers/Pascal's triangle
- Catamorphism
- Centre and radius of a circle passing through 3 points in a plane
- Centroid of a set of N-dimensional points
- Change e letters to i in words
- Changeable words
- Character codes
- Chebyshev coefficients
- Check if a polygon overlaps with a rectangle
- Check if two polygons overlap
- Check that file exists
- Chemical calculator
- Cheryl's birthday
- Chinese remainder theorem
- Chinese zodiac
- Cholesky decomposition
- Chowla numbers
- Circles of given radius through two points
- Circular primes
- Cistercian numerals
- Classes
- Closures/Value capture
- Code Golf: Code Golf
- Collect and sort square numbers in ascending order from three lists
- Collections
- Colorful numbers
- Combinations
- Combinations and permutations
- Comma quibbling
- Command-line arguments
- Commatizing numbers
- Comments
- Common list elements
- Compare a list of strings
- Compare length of two strings
- Compiler/code generator
- Compiler/lexical analyzer
- Compiler/Simple file inclusion pre processor
- Composite numbers k with no single digit factors whose factors are all substrings of k
- Compound data type
- Concatenate two primes is also prime
- Concurrent computing
- Conditional structures
- Conjugate a Latin verb
- Conjugate transpose
- Consecutive primes with ascending or descending differences
- Constrained random points on a circle
- Continued fraction
- Continued fraction/Arithmetic/Construct from rational number
- Convert CSV records to TSV
- Convert seconds to compound duration
- Conway's Game of Life
- Coprime triplets
- Coprimes
- Copy a string
- Copy stdin to stdout
- CORDIC
- Count how many vowels and consonants occur in a string
- Count in factors
- Count in octal
- Count occurrences of a substring
- Count the coins
- Count the coins/0-1
- Cousin primes
- Cramer's rule
- CRC-32
- Create a file
- Create a two-dimensional array at runtime
- Create an executable for a program in an interpreted language
- Create an HTML table
- CSV data manipulation
- CSV to HTML translation
- Cuban primes
- Cubic special primes
- Cullen and Woodall numbers
- Cumulative standard deviation
- Currency
- Currying
- Curzon numbers
- CUSIP
- Cyclops numbers