CGOL
Encyclopedia
CGOL is an alternative syntax for the MACLISP
Maclisp
MACLISP is a dialect of the Lisp programming language. It originated at MIT's Project MAC in the late 1960s and was based on Lisp 1.5. Richard Greenblatt was the main developer of the original codebase for the PDP-6; Jonl White was responsible for its later maintenance and development...

 programming language,
featuring an extensible algebraic notation. It was created by Vaughan Pratt
Vaughan Ronald Pratt
Vaughan Ronald Pratt , a Professor Emeritus at Stanford University, was one of the earliest pioneers in the field of computer science. Publishing since 1969, Pratt has made several contributions to foundational areas such as search algorithms, sorting algorithms, and primality testing...

.

The notation of CGOL is a traditional algebraic notation (sometimes called "infix syntax"), in the style of ALGOL
ALGOL
ALGOL is a family of imperative computer programming languages originally developed in the mid 1950s which greatly influenced many other languages and became the de facto way algorithms were described in textbooks and academic works for almost the next 30 years...

, rather than Lisp's traditional, uniformly-parenthesized syntax. The CGOL parser is based on Pratt's design for top-down operator precedence parsing, sometimes informally referred to as a "Pratt parser
Pratt parser
A Pratt parser is an improved recursive descent parser that associates semantics with tokens instead of grammar rules. It was first described by Vaughan Pratt in the 1973 paper "Top down operator precedence", and was treated in much more depth in a Masters Thesis under his supervision. Pratt...

".

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

Syntax

Special notations are available for many commonly used MACLISP
Maclisp
MACLISP is a dialect of the Lisp programming language. It originated at MIT's Project MAC in the late 1960s and was based on Lisp 1.5. Richard Greenblatt was the main developer of the original codebase for the PDP-6; Jonl White was responsible for its later maintenance and development...

 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 MACLISP
Maclisp
MACLISP is a dialect of the Lisp programming language. It originated at MIT's Project MAC in the late 1960s and was based on Lisp 1.5. Richard Greenblatt was the main developer of the original codebase for the PDP-6; Jonl White was responsible for its later maintenance and development...

's cons function) and the infix @ operation (referring to MACLISP's append function):

a.(b@c) = (a.b)@c

The preceding example corresponds to this text in native MACLISP
Maclisp
MACLISP is a dialect of the Lisp programming language. It originated at MIT's Project MAC in the late 1960s and was based on Lisp 1.5. Richard Greenblatt was the main developer of the original codebase for the PDP-6; Jonl White was responsible for its later maintenance and development...

:

(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 MACLISP
Maclisp
MACLISP is a dialect of the Lisp programming language. It originated at MIT's Project MAC in the late 1960s and was based on Lisp 1.5. Richard Greenblatt was the main developer of the original codebase for the PDP-6; Jonl White was responsible for its later maintenance and development...

:

(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 MACLISP
Maclisp
MACLISP is a dialect of the Lisp programming language. It originated at MIT's Project MAC in the late 1960s and was based on Lisp 1.5. Richard Greenblatt was the main developer of the original codebase for the PDP-6; Jonl White was responsible for its later maintenance and development...

:

(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.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK