Lisp
Various forms of Lisp have been around since the 1950s. It is traditionally associated with artificial intelligence applications, for which Lisp is well-suited because it permits symbolic computation, can treat code as data, and simplifies building very complicated data structures. But Lisp is much more than just an AI language. It is applicable to a wide range of problems, a fact that is frequently overlooked by computer scientists but which is well known to Emacs users. Among the features that distinguish Lisp from other programming languages are:
- Fully-parenthesized prefix notation
All expressions and function calls in Lisp are surrounded by parentheses,[1] and the function name always precedes the arguments to the function. So whereas in other languages you may be able to write:
x + y
to apply the
+function to the argumentsxandy, in Lisp you write(+ x y)
"Prefix notation" means that the operator precedes the operands. When the operator is between the operands, it's called "infix notation."
Though unfamiliar, prefix notation has some benefits over infix notation. In infix languages, to write the sum of five variables you need four plus signs:
a + b + c + d + e
Lisp is more concise:
(+ a b c d e)
Also, questions of operator precedence do not arise. For example, is the value of
3 + 4 * 5
35 or 23? It depends on whether
*has higher precedence than+. But in Lisp, the confusion vanishes:(+ 3 (* 4 5)) ;result is 23 (* (+ 3 4) 5) ;result is 35
(Comments in Lisp are introduced with a semicolon ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access