4 ms·
Common Lisp does this and it's not restricted to being interpreted, you just have to include compiler, linker etc. as part of the language runtime.
by jpr 16y ago
Common Lisp does this and it's not restricted to being interpreted, you just have to include compiler, linker etc. as part of the language runtime.
- koenigdavidmj 16y agoSo if I throw a bunch of Python code into a bunch of C strings and have main() set up a Python interpreter to eval those strings, I have compiled a Python program? That seems like quite a copout.
- jrockway 16y agoWhat are you talking about? That is nothing like the topic of the article or what the parent comment is talking about. Many Common Lisp runtimes compile things that you "eval" into native machine code when the eval statement runs. That is what the parent is referring to. Many other languages have different "phases" of compilation. An example is Perl 5's BEGIN, which is Perl code that runs at compile time. This means you can write Perl to affect the compilation of the Perl program. (Why would you do this? Here's an example. When loading the module List::Util, you want to be able to use its "first" function as though it was declared in your module. You can do this because List::Util can run some code at compile-time that installs the "first" subroutine into your namespace. Then as compilation (and runtime) continues, you will magically have that "first" subroutine in your namespace, and the program will compile properly. If there was no ability to run code at compile time, then importing stuff from a module into the caller would have to be a language feature. Making the action of running code at compile time (and installing subroutines at runtime) makes it possible to implement this without help from the language author.)