3 ms·
There is a conceptual distinction between read time, compile time, and run time, but it's only conceptual: all these things happen in a single process in an int
by ScottBurson 7y ago
There is a conceptual distinction between read time, compile time, and run time, but it's only conceptual: all these things happen in a single process in an interleaved manner. When you type an expression into the REPL, first it gets read, then it gets compiled to some extent that depends on the implementation, then it gets run. Some implementations run every expression you type through the full native-code compiler, but others just interpret the expression, expanding any macros as they encounter them. In the latter case, it's switching back and forth between "run time" and "compile time" potentially many times during the interpretation of a single expression.
It is certainly true that macros are a different kind of code from most ordinary code, because what they're doing is different. But importantly, they are written in the same Turing-complete language. I once wrote a program (a C implementation for Lisp Machines) that allowed the user to interactively execute C expressions. Obviously, it had to parse the C code according to the syntax of that language, but the parser produced list structure that consisted entirely of macro calls. The guts of the compiler were implemented as a collection of macros that translated the output of the parser into Lisp Machine Lisp. These macros did things like accessing and updating a symbol table — far beyond what you could do in a C macro.
- lispm 7y agoI can compile a file to machine code and load it into another process. The file compiler provides the 'compile-time'. The other process then provides 'load-time' and 'run-time'.
- ScottBurson 7y agoRight, you can also do it that way. I should have said "all these things can happen in a single process in an interleaved manner".
- ScottBurson 7y agoIf anyone's still reading, I can't resist adding that I was doing type checking by macro expansion — a technique that was the subject of a 2017 POPL paper [0] — in 1983. [0] https://www.ccs.neu.edu/home/stchang/pubs/ckg-popl2017.pdf https://www.ccs.neu.edu/home/stchang/pubs/ckg-popl2017.pdf
- zeveb 7y agoThat's so cool! Yet another example of Lisp enabling what other languages get in the way of.