| CGOL | |
|---|---|
| Paradigm | procedural,imperative,structured |
| Designed by | Vaughan Pratt |
| First appeared | 1973 |
| Influenced by | |
| ALGOL,FORTRAN,MLisp | |
CGOL[1][2] (pronounced"see goll") is an alternative syntax featuring an extensible algebraic notation for theLisp programming language. It was designed forMACLISP byVaughan Pratt and subsequently ported toCommon Lisp.[3]
The notation of CGOL is a traditionalinfix notation, in the style ofALGOL, rather than Lisp's traditional, uniformly-parenthesizedprefix notation syntax. The CGOL parser is based on Pratt's design fortop-downoperator precedenceparsing,[4][5] 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 earlierLISP 2 project. Lisp 2 was a successor toLISP 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:
foriin1tondoforkin1tondo(ac:=0;forjin1tondoac:=ac+a(i,j)*b(j,k);c(i,k):=ac)
CGOL has an infix. operation (referring to Common Lisp'scons function) and the infix@ operation (referring to Common Lisp'sappend function):
a.(b@c) = (a.b)@c
The preceding example corresponds to this text in native Common Lisp:
(EQUAL(CONSA(APPENDBC))(APPEND(CONSAB)C))
CGOL usesof to read and set properties:
'father'ofx:='brother'ofrelativeofy
The preceding example corresponds to this text in native Common Lisp:
(PUTPROPX(GET(GETYRELATIVE)'BROTHER)'FATHER)
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:
(LAMBDA(XY)(QUOTIENT1(SQRT(PLUS(EXPTX2)(EXPTY2)))))
The syntax of CGOL is data-driven and so both modifiable and extensible.
CGOL is known to work onArmed Bear Common Lisp.[6]
The CGOL source code and some text files containing discussions of it are available as freeware fromCarnegie-Mellon University's Artificial Intelligence Repository.[3]