Hacker News new | ask | show | jobs
by kazinator 972 days ago
"Homoiconic" means that code definitions are stored in the original textual form, or possibly in a tokenized form from which the text is easily recovered. Thus the program's definitions may be edited, without referring to external source code.

Bash is homoiconic because you can type "set" with no arguments, and see all the function definitions in their original syntax (albeit reformatted and without comments). You can copy and paste these definitions, editing them in between.

In Common Lisp, the perhaps little-known ed function supports homoiconicity. Function definitions whose original definitions is available may be edited. (Like Bash's set, ed will serve you up a reformatted function without comments.)

Homoiconicity is mostly stupid and irrelevant, and an earmark of immature, naively implemented languages. A Lisp which compiles every definition that is fed into it, throwing away the original nested lists, cannot support a function like ed, and fails to be homoiconic, yet has all the oft discussed advantages of Lisp.

A feature that is close to homoiconicity that is useful is a REPL with history recall. In a REPL with history recall, we can write definitions. Even if those definitions are compiled, so the language image has no record of the code, the REPL has the original text in memory. So by history recall, we satisfy the use case of the programmer who wants to recall a definition, edit it and replace it. Or some of those use cases. Obviously, a program doesn't come with a REPL history of its definitions; only one that we made in the REPL.