[ACCEPTED]-What exactly does homoiconicity mean?-homoiconicity

Accepted answer
Score: 15

It means "code as data" which is a general 4 characteristic of Lisp family.

(add 2 3)

Just like 3 above string, which is both a list and also 2 a function call. The "Homo" prefix stands 1 for this characteristic.

Score: 12

Scheme is homo-iconic because its programs 17 have an interpretation as data structures.

'(define (foo x) (* x x))

is 16 a list, the first element of which is define, the 15 second (foo x) (a list), and so on. The quote mark 14 ' means: don't interpret this, leave it as 13 a list. If we remove the ' we get

(define (foo x) (* x x))

which is 12 a Scheme function definition. Because Scheme 11 program definitions are nested list expressions 10 (and thereby a sort of "syntax tree literals"), and 9 Scheme is a dynamic language, you can play 8 tricks with this to build very powerful 7 macro/code generating systems.

Now Java isn't 6 homo-iconic simply because it doesn't provide 5 these kind of "program literals" that evaluate 4 to parse tree fragments. Of course, you 3 can define a string

String helloWorld =
   "class Hello { public static void main(System.out.println(\"Hello, world!\"); }";

which you could parse 2 and feed to a compiler, but that's awkward, because 1 it's a string rather than a structured term.

Score: 3

Homoiconicy can mean different things to 20 different people. Originally, it was defined in 19 the context of the language TRAC, as such:

Because 18 TRAC procedures and text have the same representation 17 inside and outside the processor, the 16 term homo-iconic is applicable, from homo 15 meaning the same, and icon meaning representation.

However, that 14 definition is problematic, because it is 13 hard to precisely pin down what is meant 12 by internal and external representations. It 11 is also not at all what most people mean 10 by it today.

Today, most people probably 9 mean something along the lines of the accepted 8 answer by Mike Yang here, namely that the 7 represenation of structured data in the language is 6 elegant (literal syntax), and that such 5 datastructures are themselves the main means of 4 representating code.

To confuse matters further, this 3 concept is often called "code as data" (which is 2 itself a very overloaded term).

More info 1 here:

More Related questions