Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cl-user(1): (compile (defun hello () (format t "~&Hello~%")))
- hello
- nil
- nil
- cl-user(2): (excl:fasl-write (symbol-function 'hello) "/tmp/hello.fasl")
- t
- cl-user(3): (excl:fasl-read "/tmp/hello.fasl")
- (#<Function hello @ #x1000a964d2>)
- (defvar *anon*)
- (defun save-anonymous-function (fname args body)
- (let ((fname (make-pathname :type "LISP" :case :common :defaults fname)))
- (with-open-file (src fname :direction :output
- :if-does-not-exist :create :if-exists :supersede)
- (print `(defparameter *anon* (lambda ,args ,body)) src))
- (compile-file fname)))
- (defun load-anonymous-function (fname)
- (let ((*load-verbose* nil)
- (*anon* nil)) ; to avoid modifying the global one.
- (load fname)
- *anon*))
Add Comment
Please, Sign In to add comment