4 ms·
Wasn't chez scheme the dialect that let you compile scheme code at runtime as a first class thing? I remember looking into this stuff when I had it in my idea t
by LAC-Tech 3y ago
Wasn't chez scheme the dialect that let you compile scheme code at runtime as a first class thing? I remember looking into this stuff when I had it in my idea to make a configurable text editor.
I know racket is very static in this regard.
- samth 3y agoBoth Chez and Racket allow you to compile new code at runtime.
- LAC-Tech 3y agoIs that new? I'm sure I looked into this last year and it couldn't be done.
- samth 3y agoIt is certainly not new. There are some things that Racket doesn't allow, but they are very much not "compile new code". For example, you can't replace the meaning of existing modules at runtime, nor can you modify the implementation of functions that are on the stack already (both things that some runtime systems for some languages allow). But `eval` has been there since the beginning.
- ska 3y ago> Wasn't chez scheme the dialect that let you compile scheme code at runtime as a first class thing? IIRC every lisp and scheme I've used has supported this. It's pretty typical, but not universal.
- soegaard 3y agoEvaluating code at runtime is "universal". But some implementations use an interpreter for evalulating code at runtime. ChezScheme uses the compiler.
- ska 3y agoSorry, typed poorly. I meant "but not universal" instead of "if not universal". Updated now. 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.
- soegaard 3y agoConsider the case where a compiler compiles Scheme to C via C. The C compiler is available at compile time, but who knows if the user has a C compiler. Such compilers often solve the problem by using some kind of interpreter at runtime. 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`?
- ska 3y agoYes that's an obvious problem, but manageable I suppose by installing a toolchain or insisting on one when you install. 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.
- soegaard 3y agoAs you point out, it's quite common for Common Lisp compilers to produce machine code directly. In the Scheme world that's more rare and made Chez Scheme stand out. I think, that's what LAC-Tech hinted at - but I am not sure.
- LAC-Tech 3y agoExactly what I was hinting at (Well i was trying to say it outright but obviously not using the right words!)