Revision 1.0

 Marcel van der Veer


Table of contents


About Algol68G

Algol 68 was conceived as a successor to Algol 60, with special attention given to wide applicability and a rigorously defined syntax. The contribution of Algol 68 to the development of computer science comes from original design concepts which were passed on in one form or another to many of the later developed programming languages. The language has compact, orthogonal syntax and strong typing that eliminates many programming errors. It has been said that those who used the language remember it as a beautiful means of denoting algorithms.

Algol68G consists of the command-line program a68g that is an Algol 68 subset interpreter. Algol68G is a check-out system, intended for small to medium size algorithms, that first translates a program entirely into an intermediate representation whereafter the latter is interpreted. Therefore, considering function, it resembles FLACC [Mailloux 1978]. Being a check-out system, a68g is suited for small to medium size programs that solve not too complex problems. Algol68G offers multi-precision arithmetic and graphic routines, for instance for the X Window System. Although Algol68G is not a full implementation, it is more complete than Algol68C.

No warranty

The software described in this manual has no warranty, it is provided "as is". Consult the GNU General Public License for further details.

Synopsis and options

From the command-line you would use

Options are passed to a68g either from the file .a68g.rc in the working directory, the command-line or through pragmats. Precedence is as follows: pragmats supersede command-line options, command-line options supersede options in .a68g.rc. Options are not case sensitive. In the list below, bold letters denote letters mandatory for recognition. Listing options, tracing options and -pragmat, -nopragmat, take their effect when they are encountered in a left-to-right pass of the program text, and can thus be used, for example, to generate a cross reference for a particular part of the user program.

One-liners

-print unit
Command-line only. Prints the value yielded by Algol 68 unit unit. In this way a68g can execute one-liners from the command-line. The one-liner is written in file .a68g.x in the working directory. See also -execute.
-execute unit
Command-line only. Executes Algol 68 unit unit. In this way a68g can execute one-liners from the command-line. The one-liner is written in file .a68g.x in the working directory. See also -print.

Memory size

a68g manages allocation and de-allocation of heap space. However, if memory would be unbound, a68g might claim all available memory before the garbage collector is called. This would impede overall system performance. Therefore memory size is bound.

-heap number
Sets heap size to number kB. This is the size of the block that will actually hold data, not handles. At run-time a68g will use the heap to store temporary arrays, so even a program that has no heap generators requires some heap space, and might even invoke the garbage collector. Current default value is 4096.
-handles number
Sets handle space size to number kB. This is the size of the block that hold handles that point to data in the heap. A reference to the heap does not point to the heap, but to a handle as to make it possible for the garbage collector to compact the heap. Current default value is 1024.
-frame number
Sets frame stack size to number kB. A deeply recursive program with many local variables may require a large frame stack space. Current default value is 512.
-stack number
Sets expression stack size to number kB. A deeply recursive program may require a large expression stack space. Current default value is 512.

Listing options

-extensive
Generates extensive listing, including source listing, syntax tree, cross reference etcetera. This listing can be quite bulky.
-listing
Generates concise listing.
-moids
Generates overview of moids in listing file.
-preludelisting
Generates a listing of preludes.
-source, -nosource
Starts (or stops) listing of source lines in listing file.
-statistics
Generates statistics in listing file.
-terminal
Echo listing file to stdout.
-tree, -notree
Generates syntax tree listing in listing file. This option can make the listing file bulky, so use considerately.
-unused
Generates an overview of unused tags in the listing file.
-xref, -noxref
Starts (or stops) generating a cross reference in the listing file.

Miscellaneous options

-assertions, -noassertions
Starts (or stops) elaboration of assertions.
-trace, -notrace
Starts (or stops) tracing of a running program.
-help
Provides an overview of options.
-check, -norun
Check syntax only, interpreter does not start.
-nowarnings
Suppresses warning messages.
-pragmats, -nopragmats
Starts (or stops) elaboration of pragmat items. When disabled, pragmat items are ignored, except for -pragmats.
-precision number
Sets precision for LONG LONG modes to number significant digits. The precision cannot be less than the precision of LONG modes. Note that a68g algorithms for extended precision are not really suited for precisions larger than a few thousand digits.
-timelimit number
Interrupts the interpreter after number seconds; a time limit exceeded runtime error will be given.
-verbose
a68g will inform you on its actions.
-version
States the version of the running copy of a68g.

Examples

Description of the implementation

About this Algol 68 implementation

Algol68G implements an extended subset of the language described in [Revised Report 1975]. A program is parsed and when it is found to be free of errors, the resulting syntax tree, that functions as an intermediate program representation, is interpreted offering many runtime checks; therefore Algol68G resembles FLACC [Mailloux 1978]. Algol68G employs the classical multi-pass scheme to parse Algol 68 [Lindsey 1993].

Deviations from the Revised Report

Execution speed

It is difficult to determine at forehand at what speed the interpreter will run on a certain platform. To have an idea however, Algol68G is rated with the Whetstone benchmark and performance ranges from approximately 1 MWhets on older desktops to 10 MWhets on server hardware. Note that these performances are reached with all run time checks enabled. For comparison, the table below compiles approximate Whetstone ratings in double precision, achieved on machines from the mainframe era

Known problems

Drawing using GNU plotutils

Introduction

Algol68G offers a number of routines for drawing. To this end it implements a subset of libplot from GNU plotutils. This allows for drawing in X Windows, postscript format, pseudo graphical interface format (pseudo-gif) and portable any-map format (pnm) from Algol 68. Note that Algol68G is not an Algol 68 binding for libplot.

A plotter (window, postscript file, etcetera) can be considered as a stream to which plotting commands are written, hence Algol68G considers plotters to be objects of mode REF FILE. This seems consistent with the design of Algol 68 transput as a file is associated with a channel that describes the device, and therefore can be considered as a description of a device driver.

A plotter must be opened and closed, just like any file. To specify the file to be a drawing device, stand draw channel is declared in the standard environment, that yields TRUE when inspected by draw possible. To specify details on the plotter type and page size, a procedure make device has to be used. For example:

Implemented drawing routines are part of the standard environment.

Setting up a graphics device

Specifying colours

Drawing objects

Drawing text

An elementary vector library

Algol68G implements a small vector library that relaxes the limitation that the interpreter poses on speed in arithmetic operations. Using these elementary procedures, more complex operations can be programmed. Consider for instance multiplication of a matrix m times a vector b:

The procedures in the vector library are optimised for speed, although they still perform runtime checks on vector length, initialisation, assignment to NIL and division by zero. Please note that the procedures strictly process vector elements sequentially as in

Therefore, take care when passing overlapping slices as arguments.

Following is a list of available procedures.

Assertions as pre- or postconditions

Algol68G supports an extension called assertions. Assertions can be viewed in two ways. First, they provide a notation for invariants that can be used to code a proof of correctness together with an algorithm. Hardly anyone does this, but assertions make for debugging statements. The syntax for assertions reads

Under control of the 'assertions' and 'noassertions' pragmat items, the enquiry clause of an assertion is elaborated at runtime. If the enquiry clause yields FALSE, the program is terminated and a runtime error is generated. Example:

Published in Algol 68

More on Algol 68 Genie



© 2002-2024 J.M. van der Veer (jmvdveer@xs4all.nl)