CGOL | |
Paradigm: | procedural, imperative, structured |
Year: | 1973 |
Designer: | Vaughan Pratt |
Influenced By: | ALGOL, FORTRAN, MLisp |
CGOL (pronounced "see goll") is an alternative syntax featuring an extensible algebraic notation for the Lisp programming language. It was designed for MACLISP by Vaughan Pratt and subsequently ported to Common Lisp.
The notation of CGOL is a traditional infix notation, in the style of ALGOL, rather than Lisp's traditional, uniformly-parenthesized prefix notation syntax. The CGOL parser is based on Pratt's design for top-down operator precedence parsing, sometimes informally referred to as a "Pratt parser".
Semantically, CGOL is essentially just Common Lisp, with some additional reader and printer support.
CGOL may be regarded as a more successful incarnation of some of the essential ideas behind the earlier LISP 2 project. Lisp 2 was a successor to LISP 1.5 that aimed to provide ALGOL syntax. LISP 2 was abandoned, whereas it is possible to use the CGOL codebase today. This is because unlike LISP 2, CGOL is implemented as portable functions and macros written in Lisp, requiring no alterations to the host Lisp implementation.
Special notations are available for many commonly used Common Lisp operations. For example, one can write a matrix multiply routine as:CGOL has an infix .
operation (referring to Common Lisp's cons
function) and the infix @
operation (referring to Common Lisp's append
function):
a.(b@c) = (a.b)@c
The preceding example corresponds to this text in native Common Lisp:
CGOL uses of
to read and set properties:
The preceding example corresponds to this text in native Common Lisp:
This illustrates how CGOL notates a function of two arguments:
\x,y; 1/sqrt(x**2 + y**2)
The preceding example corresponds to this text in native Common Lisp:
The syntax of CGOL is data-driven and so both modifiable and extensible.
CGOL is known to work on Armed Bear Common Lisp.
The CGOL source code and some text files containing discussions of it are available as freeware from Carnegie-Mellon University's Artificial Intelligence Repository.