Take the 2-minute tour ×

I'm reading about LISP.

I understand how prefix notation works at a certain level, but I was wondering if there are any tricks to making it intuitive.

share|improve this question
Apart from practice, you mean? –  delnan Aug 4 '11 at 12:43
User RPL is by far my favorite flavor of LISP. It doesn't even have any parentheses! en.wikipedia.org/wiki/RPL_(programming_language) I miss using my HP 50g :-( –  Robbie Aug 18 '11 at 18:20
At first it seemed unintuitive, but now I think it's wonderful, and I've mostly done reading. It is actually how we speak: "The sum of..., the product of..." However, it does require a different kind of reading. Now you simply apply the operator to all the arguments, instead of reading them in a line. –  Mark C Aug 27 '11 at 21:43
What's wrong with the prefix notation? Almost all the languages are using it. Function calls are almost always prefix. –  SK-logic Aug 29 '11 at 10:07
Not really; "intuitive" is intuitive because you've learned it in a form of mathematical conventions for >20+ years. Since only LISP and maybe a few other languages use this convention, and you'll still learn the other one much more, it will hardly ever become equally "intuitive". And we're talking only about simple expressions here (2+3 ... how would you like to try a "half a page" liner? :) –  Rook Aug 29 '11 at 15:41
add comment

5 Answers

up vote 4 down vote accepted

Mentally reading it left to right as spoken language with the proper verbs can help. For example (+ 3 2) could be "add three and two". In the more general case, you can say "perform $operation on $operands". Applied to the same case: "Perform the add operation on three and two".

share|improve this answer
What would you do with ( = 1 2 ) and ( > 4 2 ) –  Rice Flour Cookies Aug 4 '11 at 19:00
You'd use rhetorical questions. :) Equal? (What?), "1 and 2! (Erm... No...) –  Arafangion Aug 9 '11 at 23:40
@RiceFlour (Hey, I grew up eating things made from rice flour--I have a gluten problem.) I would read "Is one equal to two?", or "Are the following equal?" The greater-than and less-than operators are not so natural in prefix form, but I wonder how often they are used in Lisp code. –  Mark C Aug 27 '11 at 22:11
add comment

Tricks? What for?

It doesn't feel intuitive for you yet because your mental parser isn't used to it. It'll become better if you just use it and read it over and over again.

share|improve this answer
I haven't even read that much of it, but now I think it is wonderful. It seems that my brain is beginning to have an almost "tactile" sense about the parentheses. I think the feeling will only become more keen. –  Mark C Aug 27 '11 at 21:47
add comment

Many languages use a mix of prefix, infix and even postfix.

Lisp just uses only prefix - by default. If sin(x) is intuitive from mathematics, then (sin x) is not far away. If move(dog,home) is a traditional procedure call, then in Lisp it is just (move dog home).

Lisp does not make any exception for mathematics and treats +, -, * and others like ordinary function calls.

share|improve this answer
add comment

You could think about is as a kind of function call:

what_to_do operators

There is nothing very special about it. If you overload operators in C++ (and many other languages that allow it) you often have to define this kind of function exactly that way:

MyClass operator+(MyClass const& x, MyClass const& y);
share|improve this answer
Yep, this is how I do it. If you step back and look at method calls in Java, C#, etc. they're really just prefix notation with the parentheses in a slightly different place: MyMethod(arg1, arg2). –  nlawalker Aug 4 '11 at 15:50
add comment

When (eventually) "Everything is a function call" (or a special form, or a macro-expansion, both having the surface syntax of "function call") clicked, it felt pretty natural.

So, for (= 1 2) I read that as 'call the numeric equals comparison on 1 and 2'.

share|improve this answer
add comment

Your Answer


