CGOL

From Wikipedia, the free encyclopedia
Jump to: navigation, search
This article is about the programming language. For the cellular automata, see Conway's Game of Life.
CGOL
Paradigm(s) procedural, imperative, structured
Designed by Vaughan Pratt
Appeared in 1973
Influenced by ALGOL, FORTRAN, MLisp

Description[edit]

CGOL[1][2] (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[3] to Common Lisp.

The notation of CGOL is a traditional algebraic notation (sometimes called 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[4][5], sometimes informally referred to as a "Pratt parser".

Semantically, CGOL is essentially just Common Lisp, with some additional reader and printer support.

Syntax[edit]

Special notations are available for many commonly used Common Lisp operations. For example, one can write a matrix multiply routine as:

for i in 1 to n do
  for k in 1 to n do
    (ac := 0;
     for j in 1 to n do
        ac := ac + a(i,j)*b(j,k);
     c(i,k) := ac)

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:

(EQUAL (CONS A (APPEND B C)) (APPEND (CONS A B) C))

CGOL uses of to read and set properties:

'father' of x := 'brother' of relative of y

The preceding example corresponds to this text in native Common Lisp:

(PUTPROP X (GET (GET Y RELATIVE) '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 (X Y) (QUOTIENT 1 (SQRT (PLUS (EXPT X 2) (EXPT Y 2)))))

The syntax of CGOL is data-driven and so both modifiable and extensible.

Status and source code[edit]

CGOL is known to work[6] on Armed Bear Common Lisp.

The CGOL source code and some text files containing discussions of it are available as freeware[7] from Carnegie-Mellon University's Artificial Intelligence Repository, as well as from Richard Fateman's homepage at the University of California, Berkeley.

References[edit]