I'm guessing this is not rocket science, but how can I run a compiled lisp file? I am using emacs and SLIME under Windows. From the SLIME menu it is straightforward to compile the file and, once it does, it spits out a wx64fsl in the same directory as my lisp source. How do I load/run this file? I've been running files by eval-ing whole blocks of code and I've been told that running the compiled version performs far better.
3 Answers
From the SLIME REPL:
,cdto change directories into the one with your lisp file(load (compile "filename.lisp"))
OR from the SLIME Menu:
SLIME > Compilation > Compile \ Load
So basically it was embarrassingly easy and there was even a menu option for it, I was just initially confused by the nomenclature. Hopefully this will help someone in the future.
Comments
Is your lisp implementation automatically compiling functions? SBCL on OS X does for me. If that's the case, I don't think you'll see any benefit from using the compiled files, other than saving compile time when loading the file.
Example taken from CLHS and tested on my setup at the REPL:
(defun f (x) x)
F
>
(compiled-function-p #'f)
T
>
In practice, I've always just used .lisp files. Never invested the time in using Make as a build tool to automatically compile lisp source code as it changes. I haven't seen any real-world benefits from using compiled fasls, at least on my setup, other than saving compile time (not speeding up run time).
And to save compile time, I use a technique where the majority of the packages/stable code are loaded up (automatically compiled) into the core file, so that compile time is minimal when I start with that core file and test some new code in a .lisp file.
1 Comment
(LOAD "whatever") will usually load and compile whatever.lisp unless a compiled file is already present with the same name and an implementation specific extension. Those files are generated with (COMPILE-FILE "whatever.lisp") or in emacs with SLIME using the keys C-c C-k.
As Rainer recommends, you probably should be using ASDF to define your system, and most certainly quicklisp for managing dependencies and installing packages. There is also quickproject which I recommend for creating a project template. You can install it with quicklisp easily.