I'm totally confused about clojure's reader. The input that the reader's
read
function gets passed can be source file or some ASCII text directly typed into the REPL. The reader then produces a data structure and passes it to the compiler so it could be evaluated.
What I don't understand is how that data structure 'looks like' for a compiler?
read-string
function does the same as the reader's read
function when it gets passed a string. read-string "(+ 1 2 3)")
returns (+ 1 2 3)
. Does it mean then that (+ 1 2 3)
is the exact representation which gets passed to the compiler as an internal data structure?
Why is the reader important as a separate function, idea, phase? Why doesn't the compiler serialize those reader forms and convert it to data structures internally?
Another question is: It is possible to write a program that would generate data structures directly and so they could then be directly passed to the compiler (without stepping through the reader stage), neither through a macro coded in a source file. How can try to do this?
Very nice explation: What are the tasks of the "reader" during Lisp interpretation?