Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storing a Lisp compiled function in a database

CLISP allows us to do

(compile nil #'(lambda(x) (+ x 1)))

This returns a compiled function object:

#<COMPILED-FUNCTION NIL>

Is it possible to export this as a binary string, in order to persist it? Say, saving it in a database, and later be able to load and run the compiled function.

like image 635
Diogo Franco Avatar asked Aug 11 '26 11:08

Diogo Franco


1 Answers

Not in portable Common Lisp.

Instead write the function to a file, compile the file with COMPILE-FILE. Then you have the compiled code on the file system. You can later load the file and run the function. You could also store the file contents into the database. If you need it later, you would need to export the data from the database into a file and call LOAD to load the file.

like image 125
Rainer Joswig Avatar answered Aug 13 '26 04:08

Rainer Joswig