# LISP Infix Syntax Survey

In the lisp community, especially Common Lisp, many seasoned lispers hold the idea that, those who dislike lisp's nested parenthesis syntax are outsiders, who don't get lisp. This is factually incorrect.

This page lists lisp projects or languages that implement alternative syntax to solve the controversial nested parenthesis (S-expression; sexp) problem. I probably missed some. Please comment if you find any missing.

### M-Expression, John McCarthy LISP (1958)

The project of defining M-expressions precisely and compiling them or at least translating them into S-expressions was neither finalized nor explicitly abandoned. It just receded into the indefinite future, and a new generation of programmers appeared who preferred internal notation to any FORTRAN-like or ALGOL-like notation that could be devised.

[History of Lisp By John McCarthy. At http://www-formal.stanford.edu/jmc/history/lisp/lisp.html , accessed on 2013-06-23 ]

### CGOL (1973)

• 1973 CGOL

Vaughan Ronald Pratt is known for his work in MACLISP, the Knuth–Morris–Pratt algorithm, and his work together with Knuth, and James H. MorrisCGOL[1][2] (pronounced “see goll”) is an alternative syntax for the MACLISP programming language, featuring an extensible algebraic notation. It was created by Vaughan Ronald Pratt.

### Mathematica (1988)

Mathematica has a regular nested notation, all of the form `f[…]`

. Here's a example:

SetDelayed[vectorAngle[List[Pattern[a1,Blank[]],Pattern[a2,Blank[]]]], Module[List[x,y], CompoundExpression[ Set[List[x,y], N[Times[List[a1,a2], Power[Sqrt[Plus[Power[a1,2],Power[a2,2]]],-1]]]], If[Equal[x,0], If[SameQ[Sign[y],1],Times[Pi,Power[2,-1]], Times[Times[-1,Pi],Power[2,-1]]], If[Equal[y,0],If[SameQ[Sign[x],1],0,Pi], If[SameQ[Sign[y],1],ArcCos[x], Plus[Times[2,Pi],Times[-1,ArcCos[x]]]]]]]]]

This is isomorphic to lisp's S-Expression, and is called “FullForm” in Mathematica.

Mathematica also has a layer on top, called InputForm, corresponding to lisp's concept of M-expression. Here's the same code in InputForm:

vectorAngle[{a1_, a2_}] := Module[{x, y}, {x, y} = {a1, a2}/Sqrt[a1^2 + a2^2] // N; If[x == 0, If[Sign@y === 1, Pi/2, -Pi/2], If[y == 0, If[Sign@x === 1, 0, Pi], If[Sign@y === 1, ArcCos@x, 2 Pi - ArcCos@x] ] ] ]

The InputForm and FullForm are **syntactically equivalent**, and you can code using either or mixed.
You can also press a button in the Mathematica editor to convert one to the other.

Mathematica also has StandardForm, that renders expression in 2D math notation as in TeX in real time. In general, input and outputs are automatically rendered in StandardForm.

### Dylan (1992)

• ~1995 Dylan (programming language). A Common Lisp based language created by mostly Apple, aimed as the industrial LISP.

Initially, Dylan used a Scheme-like prefix syntax, which is based on s-expressions…

By the time the language design was completed, it was changed to an Algol-like syntax, designed by Michael Kahl, with the expectation that it would be more familiar to a wider audience of programmers

### Scheme srfi-49 (2003)

[Scheme srfi-49 Indentation-sensitive syntax By Egil Möller. At http://srfi.schemers.org/srfi-49/srfi-49.html ]

This SRFI describes a new syntax for Scheme, called I-expressions, with equal descriptive power as S-expressions. The syntax uses indentation to group expressions, and has no special cases for semantic constructs of the language. It can be used both for program and data input.

It also allows mixing S-expressions and I-expressions freely, giving the programmer the ability to layout the code as to maximize readability.

### Readable Lisp S-expressions Project (2006)

[Readable Lisp S-expressions Project By David A Wheeler. At http://readable.sourceforge.net/ , accessed on 2013-06-23 ]

This is a syntax transformation tool, for Common Lisp and Scheme Lisp and other Lisps.

On its home page, it has a very well presented video, explaining the whys and hows.

It also has a comprehensive survey of the alternative lisp syntax issue. See:

[Readable s-expressions and sweet-expressions: Getting the infix fix and fewer parentheses in Lisp-like languages By David A Wheeler. At http://www.dwheeler.com/readable/readable-s-expressions.html , accessed on 2013-06-23 ]

### Clojure Lisp (2007)

Here is a sample Clojure code, from Wikipedia:

(let [i (atom 0)] (defn generate-unique-id "Returns a distinct numeric ID for each call." [] (swap! i inc)))

Here is some syntax example from Clojure's manual.

- list
`(a b c)`

- vector
`[1 2 3]`

- maps
`{:a 1 :b 2}`

- sets
`#{:a 1 :b 2}`

- deftype
`#my.klass_or_type_or_record[:a :b :c]`

- defrecord
`#my.record{:a 1, :b 2}`

- metadata map.
`^{:a 1 :b 2} [1 2 3]`

- regex
`(#"pattern")`

- anonymous function literal.
`#(...)`

⇒`(fn [args] (...))`

### Arc Lisp (2009)

• Arc Lisp, a new lisp created by the famous Paul Graham. Arc (programming language) .

I've used Lisp my whole programming life and I still don't find prefix math expressions natural. —Paul Graham

We also plan to let programmers omit parentheses where no ambiguity would result, and show structure by indentation instead of parentheses. I find that I spontaneously do both these things when writing Lisp by hand on whiteboards or the backs of envelopes. —Paul Graham http://www.paulgraham.com/arcll1.html

In Arc, you can write

`(if a b c d e)`

to mean:

(if a b (if c d e))

source: ~~http://ycombinator.com/arc/tut.txt~~

### Racket Lisp (2011)

• ~2012 Racket Scheme Lisp. () [] {} can all be used interchangeably.

Racket was renamed from PLT Scheme Lisp in 2010. It was lead by Matthias Felleisen. Matthias is well known in lisp programing community at least as lisp book author. He co-wrote:

- How to Design Programs Buy at amazon
- A Little Java, A Few Patterns Buy at amazon
- The Little MLer Buy at amazon
- The Little Schemer Buy at amazon
- The Seasoned Schemer Buy at amazon

I'm not sure when is the various brackets equivalence introduced.

Here is a excerpt from Racket's manual at http://docs.racket-lang.org/reference/reader.html#%28part._parse-pair%29 .

When the reader encounters a (, [, or {, it starts parsing a pair or list; see Pairs and Lists for information on pairs and lists.

To parse the pair or list, the reader recursively reads data until a matching ), ], or } (respectively) is found, and it specially handles a delimited .. Pairs (), [], and {} are treated the same way, so the remainder of this section simply uses “parentheses” to mean any of these pair.

…

For syntactical advantage of multiple types of nesting bracket, see:

## Clojure Infex: mixfix-clj (2015)

[2017-05-23 https://github.com/awto/mixfix-clj ]

## Other, Smaller Players or Defunct Projects

### wisp (2013)

[wisp: Whitespace to Lisp: An indentation to brackets preprocessor to get more readable Lisp By Arne Babenhauserheide. At http://draketo.de/light/english/wisp-lisp-indentation-preprocessor , accessed on 2013-06-23 ]

### Common Lisp cl-2dsyntax

• Common Lisp cl-2dsyntax (an indentation-sensitive reader system) ~~http://lisp.hyperprostor.unas.cz/cl-2dsyntax/~~

The cl-2dsyntax is an indentation-sensitive reader system. Published in the public domain. Because lispers read the code by indentation and not by parentheses, I've decided to write a reader macro for this.

It's up to you when to use this, I'm going to use it in a dumb editor such the Notepad (when I can't choose better).

am not sure who wrote it, when, or whether this is robust library or a proof-of-concept code.

### lisp-smile; LISPIN (2005)

• Genyris Scripting Language http://sourceforge.net/projects/genyris/

• Lisp without parentheses: LISP INdented ~2005. DEAD. http://wayback.archive.org/web/20080517144846id_/http://www.lispin.org/

• lisp-smile (defunct) https://code.google.com/p/lisp-smile/

## Others

Jecel [je…@merlintec.com] added the following, but they may not qualify.

Richard Fateman mentioned that CGOL is also available in Common Lisp.I don't seen the ones I have used in this list:

- RLISP, part of the Reduce package (late 1960s) Reduce (computer algebra system)
- MuSIMP, an extension of MuLisp and part of the MuMath package (late 1970s) MuMATH
I would also include Logo (programming language) as an example of a Lisp with a different syntax. To me, the only real difference between Logo and a “real” Lisp is that its EVAL (called RUN) doesn't take an environment as an argument.

— Jecel

There's a version of CGOL for common lisp, I believe. I haven't tried it in many years, but here's a link.

comp.lang.lisp discussion https://groups.google.com/forum/#!topic/comp.lang.lisp/R7lYioqThLs