u/Suitable_Click_3967

File compilation without a file

Greetings!

I know one can use COMPILE to compile a function for later use in the current image, and COMPILE-FILE to read a file, compile the code in it, and save a loadable version of the code (FASL).

I'm working on a system that generates Lisp forms programmatically, however it does so outside of the usual read-compile-load cycle. You can imagine a DSL with its own syntax, that is mapped to Lisp forms.

Now, at some point I would like to compile the generated code "as if" it was normal Lisp code, and save it into a FASL. I know I can PRINT it to a temporary file and call COMPILE-FILE on that, however, it feels like a suboptimal solution.

Perhaps there's no portable way of doing that, but I would be happy with implementation-specific code, and the temporary file hack as a fallback.

reddit.com
u/Suitable_Click_3967 — 22 hours ago