Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Lisp’s unusual syntax is connected to its expressive power. How? Not because of “homoiconicity”, a word that has no meaning but leaves people somewhat impressed, because it sounds fanciful and mathematical. It’s because of uniformity.

No, it _is_ because of homoiconicity, which though a fancy word, does mean something: code is data. That is the reason Lisp syntax works. Clojure is less uniform, but it is still homoiconic, and that is why it has the same powers as CL.




Doug McIlroy coined homoiconic as meaning that the programs are stored in the way that the programmer has entered them.

The POSIX shell is homoiconic because after you have defined some functions, you can execute the command "set" (with no arguments) to see the definitions. They are stored in a form that can be copy and pasted into the shell. (There may be reformatting and comments removed).

The homoiconic feature in Lisp (Common Lisp) is the ED function. It will recall the textual definition of a function, allowing it to be edited.

The big idea in Lisp of using a data structure for manipulating code isn't homoiconic; the data structure definitely isn't in the source code format. It's homoiconic to the extent that uncompiled code can be stored as a data structure and converted back to a character-level of representation. (This is possible due to something that Lisp calls print-read consistency, an important concept in Lisp.)

The code-to-code transformations in Lisp do not work by converting code to text and back again.

We can take advantage of that even if we go through some front-end that provides a surface syntax, like infix.cl, which loses homoiconicity.

So rather that homoiconicity, the two concepts important in Lisp are print-read consistency and code as a data structure.


Code is also data in C++, because a source file is a vector of bytes, which is a type of data that C++ can manipulate.

I think when people say “code is data” what they really mean is something more specific, like the AST is easy to access and manipulate in the language.


When people say 'code is data' they obviously don't mean that source code is stored in a text file which consists of bytes...

(def add (x y) (+ x a))

(def sub (x y) (- x y))

(add 1 2) # 3

(sub 1 2) # -1

(first '(add 1 2)) # 'add

(rest '(add 1 2)) # (list 1 2)

(apply 'sub (rest '(add 1 2))) # -1

(reverse '(add 1 2) # '(2 1 add)

Excuse my pseudo lisp quote syntax, it's been a while.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: