I know racket is very static in this regard.
I know racket is very static in this regard.
IIRC every lisp and scheme I've used has supported this. It's pretty typical, but not universal.
But some implementations use an interpreter for evalulating code at runtime. ChezScheme uses the compiler.
What I was saying is that every implementation I have used did this, not that all of them do. It seem common.
FWIW I've done a lot more CL than scheme, though.
Compilers that compile directly to machine code do not have similar problems.
For fun, do you know a Common Lisp implementation that compiles via C? How do they implement `eval`?
(funcall (compile nil `(lambda () ,form)))
Lisps that are not based purely on compilation can have an eval function that walks the source code and interprets it. Or there could be a VM.So the question is really, how do Lisps that compile to C implement the dynamic compile function? Typically it's all part of the same framework as file compilation.
There is a run-time dependency on the C compiler: for run-time compile to work, it has to be installed. The compile function writes something to a file, or perhaps a pipe. The compiler is invoked and produces a .o file; the function then loads that into the image and bind it to a funcall-able object.
It's a dependency that's a bit hard to swallow, since a C toolchain is hundreds of megabytes nowadays.
The post I was replying to was about scheme's in general though, not scheme->c implementations, right? Anything with an intermediate language or machine language output avoids this problem...
At any rate, the CL's I've used most have native compilers. I think GCL is CL via c, but can't remember the details of its implementation. In any case 'eval and 'compile are not equivalent, and the system may change whether or not 'eval compiles first or just interprets, depending on settings.
[update] I was curious, so had a look at https://get.scheme.org/
Not sure how complete that list is, but that has 4 native compilers and 3 scheme-to-c, which I guess leaves the other dozen or so interpreted, but that gets muddied with intermediate languages and retargetable (e.g. gambit).
On a different tangent, I am suddenly reminded of:
https://blog.racket-lang.org/2011/10/on-eval-in-dynamic-lang...