I'm having a bit of trouble understanding what becomes of read macros when compiling a file of lisp code into a bytecode or raw assembly (or a fasl file for that matter). Or maybe I do understand it but don't know. I'm just really confused.
When you use a read macro, don't you have to have the source available?
If you do, then you have to be executing the source code that makes up the function of the read macro. If you don't, then how can they work when you can do stuff like read-char
?
To do that, if you want to have the read macro use aforedefined variables, you have to be executing all the code before it, so this becomes runtime which messes up everything.
If you don't run the code before it, then the stuff defined above it won't be available.
What about functions or compiler macros that define read macros? I would assume they wouldn't work at all unless you require
or load
a file or something that isn't compiled. But if they were compiled, then they wouldn't be able to use them?
If some of my guesses are correct, then it means there is a large difference in "what data will be available to macros" and "what macros will be available to functions" depending on whether you are compiling an entire file to be run later or interpreting a file one line at a time (that is, reading, compiling, and evaluating one expression after another).
In short, it seems like that to compile one line to a form where it can be executed without further macro processing or whatever, you have to read, compile, and run the previous lines.
Remember again that these questions apply to compiling lisp, not interpreting it where you can run each line as it comes in.
Sorry for my rambling, but I am new to lisp and want to know more how it works.