Where can I get more information on Homoiconicity?
Explore lisp or schema. Language is a data structure. lisp code and lisp data structures have the same syntax rules.
If you learn tcl, you can work with a language that is procedural and the syntax rules of the data structure are the same as the syntax rules of the programming language.
This is not - strictly speaking - a functional programming problem. This is more of a problem with multiple languages where the syntax rules for the data and the syntax rules for the language are the same.
source to share
REBOL is a homoiconic language. A block!
REBOL datatype is a set of square brackets that contain any valid REBOL tokens, similar to an S-expression in Lisp. For instance:
series: [1 2 3 4]
foreach item series [
print item
]
Now let's put it a little differently:
series: [1 2 3 4]
for-body: [print item] ; This is the body of our foreach
foreach item series for-body
Although it was declared as data, we treated the block for-body
as code when we passed it to the function foreach
. If we ask REBOL what the type of the first element in the block for-body
is type? first for-body
- it will tell us word!
, not function!
(or native!
or action!
) or any other REBOL function types). The reason is that as data for-body
, it's just an invaluable chunk of REBOL words. When we pass it foreach
, then it gets evaluated as code.
Some have called REBOL "like Lisp but no parentheses", and I personally prefer it to Lisp, but you can't. However, it is a great language to start when you want to learn about homoiconicity, a subject that I find fascinating.
source to share