4 ms·
They didn't. But I think I understood it anyway and can explain it to you. As a result of Lisp being in prefix notation, which is just a fancy way of saying yo
by rthomas6 12y ago
They didn't. But I think I understood it anyway and can explain it to you.
As a result of Lisp being in prefix notation, which is just a fancy way of saying you always put the action first (for instance you add numbers like (+ x y z)), that design choice results in EVERY part of the language having the same syntax. That is, everything is an action that eventually returns a value, and it all is used the same way. There are no special syntaxes -- loops, conditionals, function definitions, everything. Since it's all the same, everything all the way up to the top level is one action composed of other actions chained together.
Parentheses in Lisp languages are used differently than other languages: parentheses are used for grouping and ordering in other languages, but in Lisps they're used to denote scope. The first word after an open paren is always an action, and every word thereafter is always an argument. Then arguments can be a lower level of scope which performs another action, and so on.
So really, Lisp has almost no syntax at all, and a Lisp program is nothing but a big tree of actions that start at the top level and work down (sort of).
- pkaye 12y ago"Reverse polish notation" is postfix notation where the action is last. For example Postscript or Forth. Lisp is prefix notation where the action is first.
- rthomas6 12y agoOops, corrected. Thanks!
- agentultra 12y ago> So really, Lisp has almost no syntax at all, and a Lisp program is nothing but a big tree of actions that start at the top level and work down (sort of). I've heard of it described as, "programming in the AST." You don't have to think hard about how an expression will be interpreted. In fact you can get very far with just the substitution model of eval and apply as they started off with in the SICP lectures.
- tarentel 12y agoThat's usually how I explain it to people if I know they've taken a compiler class or know about ASTs. If not I'll usually explain Lisp as a language having no order of operation rules because it's syntax are the rules.