CGOL

Last updated
CGOL
Paradigm procedural, imperative, structured
Designed by Vaughan Pratt
First appeared1973
Influenced by
ALGOL, FORTRAN, MLisp

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 to Common Lisp. [3]

Contents

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, [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 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.

Syntax

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

<nowiki/>foriin1tondoforkin1tondo(ac:=0;forjin1tondoac:=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(CONSA(APPENDBC))(APPEND(CONSAB)C))

CGOL uses of 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.

Status and source code

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

The CGOL source code and some text files containing discussions of it are available as freeware from Carnegie-Mellon University's Artificial Intelligence Repository. [3]

Related Research Articles

Dylan (programming language)

Dylan is a multi-paradigm programming language that includes support for functional and object-oriented programming (OOP), and is dynamic and reflective while providing a programming model designed to support generating efficient machine code, including fine-grained control over dynamic and static behaviors. It was created in the early 1990s by a group led by Apple Computer.

Lisp (programming language) Programming language family

Lisp is a family of programming languages with a long history and a distinctive, fully parenthesized prefix notation. Originally specified in 1958, Lisp is the second-oldest high-level programming language still in common use. Only Fortran is older, by one year. Lisp has changed since its early days, and many dialects have existed over its history. Today, the best-known general-purpose Lisp dialects are Racket, Common Lisp, Scheme, and Clojure.

Polish notation (PN), also known as normal Polish notation (NPN), Łukasiewicz notation, Warsaw notation, Polish prefix notation or simply prefix notation, is a mathematical notation in which operators precede their operands, in contrast to the more common infix notation, in which operators are placed between operands, as well as reverse Polish notation (RPN), in which operators follow their operands. It does not need any parentheses as long as each operator has a fixed number of operands. The description "Polish" refers to the nationality of logician Jan Łukasiewicz, who invented Polish notation in 1924.

Rebol is a cross-platform data exchange language and a multi-paradigm dynamic programming language designed by Carl Sassenrath for network communications and distributed computing. It introduces the concept of dialecting: small, optimized, domain-specific languages for code and data, which is also the most notable property of the language according to its designer Carl Sassenrath:

Although it can be used for programming, writing functions, and performing processes, its greatest strength is the ability to easily create domain-specific languages or dialects

S-expression

In computer programming, an S-expression is an expression in a like-named notation for nested list (tree-structured) data. S-expressions were invented for and popularized by the programming language Lisp, which uses them for source code as well as data.

In computer science, Backus–Naur form or Backus normal form (BNF) is a metasyntax notation for context-free grammars, often used to describe the syntax of languages used in computing, such as computer programming languages, document formats, instruction sets and communication protocols. They are applied wherever exact descriptions of languages are needed: for instance, in official language specifications, in manuals, and in textbooks on programming language theory.

In computer science, a compiler-compiler or compiler generator is a programming tool that creates a parser, interpreter, or compiler from some form of formal description of a programming language and machine.

In computer science, extended Backus–Naur form (EBNF) is a family of metasyntax notations, any of which can be used to express a context-free grammar. EBNF is used to make a formal description of a formal language such as a computer programming language. They are extensions of the basic Backus–Naur form (BNF) metasyntax notation.

In computer programming, M-expressions were an early proposed syntax for the Lisp programming language, inspired by contemporary languages such as Fortran and ALGOL. The notation was never implemented into the language and, as such, it was never finalized.

Conditional (computer programming) Programming language construct that performs actions according to boolean conditions

In computer science, conditionals are programming language commands for handling decisions. Specifically, conditionals perform different computations or actions depending on whether a programmer-defined boolean condition evaluates to true or false. In terms of control flow, the decision is always achieved by selectively altering the control flow based on some condition.

In computer programming, operators are constructs defined within programming languages which behave generally like functions, but which differ syntactically or semantically.

MLISP is a variant of Lisp with an Algol-like syntax based on M-Expressions, which were the function syntax in the original description of Lisp by John McCarthy. McCarthy's M-expressions were never implemented in an exact form.

In computer science, a relational operator is a programming language construct or operator that tests or defines some kind of relation between two entities. These include numerical equality and inequalities.

In computer science, an operator precedence parser is a bottom-up parser that interprets an operator-precedence grammar. For example, most calculators use operator precedence parsers to convert from the human-readable infix notation relying on order of operations to a format that is optimized for evaluation such as Reverse Polish notation (RPN).

Vaughan Pratt

Vaughan Pratt is a Professor Emeritus at Stanford University, who was an early pioneer in the field of computer science. Since 1969, Pratt has made several contributions to foundational areas such as search algorithms, sorting algorithms, and primality testing. More recently, his research has focused on formal modeling of concurrent systems and Chu spaces.

Syntax (programming languages) Set of rules defining correctly structured programs

In computer science, the syntax of a computer language is the set of rules that defines the combinations of symbols that are considered to be correctly structured statements or expressions in that language. This applies both to programming languages, where the document represents source code, and to markup languages, where the document represents data.

This comparison of programming languages compares the features of language syntax (format) for over 50 computer programming languages.

History of compiler construction Wikimedia history article

In computing, a compiler is a computer program that transforms source code written in a programming language or computer language, into another computer language. The most common reason for transforming source code is to create an executable program.

The history of the programming language Scheme begins with the development of earlier members of the Lisp family of languages during the second half of the twentieth century. During the design and development period of Scheme, language designers Guy L. Steele and Gerald Jay Sussman released an influential series of Massachusetts Institute of Technology (MIT) AI Memos known as the Lambda Papers (1975–1980). This resulted in the growth of popularity in the language and the era of standardization from 1990 onward. Much of the history of Scheme has been documented by the developers themselves.

In the programming language Lisp, the reader or read function is the parser which converts the textual form of Lisp objects to the corresponding internal object structure.

References

  1. Pratt, Vaughan R. CGOL: An Alternative External Representation for LISP Users. AI Working Paper 121. MIT Artificial Intelligence Laboratory (Cambridge, MA). 1976.
  2. Pratt, Vaughan R. CGOL - an Algebraic Notation For MACLISP users. January 27, 1977.
  3. 1 2 CGOL: Algol-like language that compiles into Common Lisp
  4. Pratt, Vaughan R. Top Down Operator Precedence. Proceedings of the ACM Symposium on Principles of Programming Languages. 1973. pp41–51.
  5. Van De Vanter, Michael L. A Formalization and Correctness Proof of the CGOL Language System (Master's Thesis). MIT Laboratory for Computer Science Technical Report MIT-LCS-TR-147 (Cambridge, MA). 1975.
  6. CGOL on ABCL Development of the Armed Bear Common Lisp implementation blog.