Questions tagged [homoiconicity]

Homoiconicity means that a language uses the same syntax for data structures as it does for statements and declarations. For example, Lisp processes list structures and is constructed with lists of symbols and other lists. XSLT transforms XML data and is written as valid XML.

21 questions
355
votes
15 answers

What makes Lisp macros so special?

Reading Paul Graham's essays on programming languages one would think that Lisp macros are the only way to go. As a busy developer, working on other platforms, I have not had the privilege of using Lisp macros. As someone who wants to understand the…
minty
  • 22,235
  • 40
  • 89
  • 106
71
votes
18 answers

Practical example of Lisp's flexibility?

Someone is trying to sell Lisp to me, as a super powerful language that can do everything ever, and then some. Is there a practical code example of Lisp's power?(Preferably alongside equivalent logic coded in a regular language.)
Peter Boughton
  • 110,170
  • 32
  • 120
  • 176
60
votes
1 answer

In what sense are languages like Elixir and Julia homoiconic?

Homoiconicity in Lisp is easy to see: (+ 1 2) is both the function call to + with 1, 2 as arguments, as well as being a list containing +, 1, and 2. It is simultaneously both code and data. In a language like Julia, though: 1 + 2 I know we can…
user2666425
  • 1,671
  • 1
  • 15
  • 21
32
votes
4 answers

Homoiconic and "unrestricted" self modifying code + Is lisp really self modifying?

I will be forward in admiting that my knowledge of Lisp is extremely minimal. However I am extremely interested in the language and plan to begin seriously learning it in the near future. My understanding of these issues is no doubt flawed, so if I…
TheIronKnuckle
  • 7,224
  • 4
  • 33
  • 56
32
votes
3 answers

What exactly does homoiconicity mean?

I was trying to understand the Wikipedia article on homoiconity, but it's too verbose and does not explain the main theory behind the word concisely. I should add that I'm not a native English speaker so I prefer simple English over academic white…
Tower
  • 98,741
  • 129
  • 357
  • 507
29
votes
10 answers

Can a compiled language be homoiconic?

By definition the word homoiconic means: Same representation of code and data In LISP this means that you could have a quoted list and evaluate it, so (car list) would be the function and (cdr list) the arguments. This can either happen at…
user141335
11
votes
5 answers

Homoiconic type theory

Lisp has the property of being homoiconic, that is, the representation of code used by the language implementation (lists) is also available to, and idiomatically used by, programs that want to represent code for their own purposes. The other major…
rwallace
  • 31,405
  • 40
  • 123
  • 242
10
votes
1 answer

Levels of Homoiconicity

This is a follow up to my previous question. I’m not convinced that Lisp code is as Homoiconic as machine code on a Von Neumann architecture. It seems obvious to me that in both cases code is represented as data, but it also seems apparent that you…
TheIronKnuckle
  • 7,224
  • 4
  • 33
  • 56
8
votes
7 answers

Traversing Scheme function as a list

Isn't it possible to treat functions in Scheme as any other list? Basically, what I want do to is something like this: (define (foo) "hello") (cdr foo) ; or similar, should return the list ((foo) "hello") I've found a similar discussion about…
csl
  • 10,937
  • 5
  • 57
  • 89
7
votes
4 answers

Is Clojure less homoiconic than other lisps?

A claim that I recall being repeated in the Clojure for Lisp Programmers videos is that a great weakness of the earlier Lisps, particularly Common Lisp, is that too much is married to the list structure of Lisps, particularly cons cells. You can…
J. Mini
  • 1,868
  • 1
  • 9
  • 38
6
votes
4 answers

Is it possible to decompose a Clojure function?

While I may incorrectly interpret the concept of homoiconicity, I've understood it as 'code being data'. So, I can write code like this: (def subject "world") (def helo '(str "Hello " subject)) At this point, helo is only data, but can be executed…
Mark Seemann
  • 225,310
  • 48
  • 427
  • 736
3
votes
2 answers

Pattern bindings for existential constructors

While writing Haskell as a programmer that had exposure to Lisp before, something odd came to my attention, which I failed to understand. This compiles fine: {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE ExistentialQuantification #-} data Foo =…
zabeltech
  • 963
  • 11
  • 27
3
votes
1 answer

How to make clojure program constructs easier to identify?

Clojure, being a Lisp dialect, inherited Lisp's homoiconicity. Homoiconicity makes metaprogramming easier, since code can be treated as data: reflection in the language (examining the program's entities at runtime) depends on a single, homogeneous…
dilvan
  • 2,109
  • 2
  • 20
  • 32
3
votes
1 answer

Which are the cases that make it hard to distinguish between code and data?

It is said code is data (and vice versa, i.e. homoiconic) in Rebol and Red. Also, it is said that it's impossible to distinguish between the two. My understanding is that there are 2 cases here: Determine with certainty code from a mix of code and…
Geeky I
  • 751
  • 6
  • 22
2
votes
2 answers

Homoiconicity and SQL

I'm currently using emacs sql-mode as my sql shell, a (simplified) query response is below: my_db=# select * from visit limit 4; num | visit_key | created | …
EoghanM
  • 25,161
  • 23
  • 90
  • 123
1
2