- CGOL
Infobox programming language
name =CGOL
paradigm = procedural, imperative, structured
year = 1976
designer = Vaughan Pratt
developer =
latest_release_version =
latest_release_date =
latest_test_version =
latest_test_date =
typing =
implementations =
dialects =
influenced_by =ALGOL ,FORTRAN ,MLisp
influenced =
operating_system =
license =
website =CGOLref|1ref|2 (pronounced "see goll") is an alternative syntax for the
MACLISP programming language,featuring an extensible algebraic notation. It was created by Vaughan Pratt.The notation of CGOL is a traditional algebraic notation (sometimes called "infix syntax"), in the style of
ALGOL , rather than Lisp's traditional, uniformly-parenthesized syntax. The CGOL parser is based on Pratt's design for top-down operator precedence parsingref|3, sometimes informally referred to as a "Pratt parser".Semantically, CGOL is essentially just MACLISP, with some additional reader and printer support.
yntax
Special notations are available for many commonly used
MACLISP 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 toMACLISP 'scons
function) and the infix@
operation (referring to MACLISP'sappend
function):a.(b@c) = (a.b)@c
The preceding example corresponds to this text in native
MACLISP :(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 :(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 :(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.
References
* Pratt, Vaughan R. CGOL: An Alternative External Representation for LISP Users. AI Working Paper 121. MIT Artificial Intelligence Laboratory (Cambridge, MA). 1976.
* V.R. Pratt. [http://zane.brouhaha.com/~healyzh/doc/cgol.doc.txt CGOL - an Algebraic Notation For MACLISP users.] January 27, 1977.
* Pratt, V.R., Top Down Operator Precedence. Proceedings of the ACM Symposium on Principles of Programming Languages. 1973. pp41-51.
Wikimedia Foundation. 2010.