Running the compiled Lisp program

I assume this is not rocket science, but how can I run a compiled lisp file? I use emacs and SLIME on Windows. It is easy to compile a file from the SLIME menu and, as soon as this happens, spits out wx64fsl in the same directory as my lisp source. How to download / run this file? I run files by analyzing entire blocks of code, and I was told that the compiled version runs much better.

+6
source share
3 answers

From SLIME REPL:

  • ,cd to change directories to lisp file
  • (load (compile "filename.lisp"))

OR from the SLIME menu:

SLIME> Compilation> Compilation \ Download

So basically it was embarrassingly easy, and for him there was even a menu option, I was just confused by the nomenclature. Hope this helps someone in the future.

+5
source

Is your lisp implementation an automatic compilation of functions? SBCL for OS X for me. If this is the case, I do not think that you will see any benefit from using compiled files other than saving compile time when downloading the file.

An example taken from CLHS and tested in my setup in REPL:

 (defun f (x) x) F > (compiled-function-p #'f) T > 

In practice, I have always used .lisp files. I have never invested time in using Make as a build tool to automatically compile lisp source code as it changes. I have not seen any real benefits of using compiled fasls, at least in my setup, except to save compilation time (without speeding up execution time).

And to save compilation time, I use a technique in which most of the packages / stable code is loaded (automatically compiled) into the main file, so the compilation time is minimal when I start from this kernel file and test some new code in the .lisp file.

+3
source

(LOAD "whatever") usually loads and compiles any.lisp, unless the compiled file already has the same name and extension for a particular implementation. These files are created using (COMPILE-FILE "whatever.lisp") or in emacs using SLIME using the Cc Ck keys.

As Rainer recommends, you should probably use ASDF to define your system and, most importantly, quicklisp to manage dependencies and install packages. There is also a quickproject that I recommend for creating a project template. You can easily install it using quicklisp.

+3
source

Source: https://habr.com/ru/post/913889/


All Articles