Comment by glouwbug
7 days ago
I believe MIT Scheme compiled directly to C by intermingling switch statements and gotos to emulate its call stack. Problem was, as programs grew, compile times weren't linear. I gave it a shot once, it was a somewhat spiritual experience:
Thanks! Do you mean MIT Scheme's C backend? I've used MIT Scheme on and off for a long time and have never touched the C backend & have no idea how it works, so this is interesting.
(MIT Scheme also has a native code compiler for Intel CPUs, which seems to be what most users of MIT Scheme (an admittedly small community) actually use.)
If you'd like to define the backend like this, it's the easiest way to compile to C; we're just repurposing C as a general-purpose assembler: https://glouw.com/2023/11/07/Switch.html
I believe MIT-scheme took it a step further with gnu extensions which allowed you to take the address of a label like &&label, which allowed for function pointers: https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
I don't see anything in the manual about MIT scheme compiling to C, just to its own native code object files and some portable bytecode...
https://www.gnu.org/software/mit-scheme/documentation/stable...
It's there, but the documentation is weak.
The release notes from long ago when that back end was released are here, and give some detail:
https://share.google/xmUnDhC7lndujD7TI
I think a very rudimentary implementation (which is easy to understand) is in the SICP book
Even MIT Scheme was used with SICP, the Scheme implementation in the book is different from MIT Scheme.
MIT Scheme was for a long period one of the leading Scheme implementations. It lacks support for Apple Silicon, so it is not as popular now, as it once was.
https://www.gnu.org/software/mit-scheme/
Yes. In Apple the memory can be writable XOR executable. MIT scheme needs to write on pages that will execute, so it will trigger the MMU..
Install chicken scheme. Then:
At ~/.csirc put:
Now you can do nearly all the execises.