How can I run SBCL code under a Unix-like operating system in a convenient way?

给你一囗甜甜゛ 提交于 2019-12-02 20:29:18
Rainer Joswig

(Answer by David James:)

We are going to make two commands in our system: one for batch compiling Lisp code and the other for easily running Lisp code:

Using your favorite editor, open a file called sbcl.compile. The content should be:

    #!/bin/bash
    sbcl --noinform --eval "(compile-file \"$1\")" --eval "(quit)" > /dev/null

Now to compile Lisp files use:

    # sbcl.compile hello.lisp

This will create a hello.fasl file.

Now to easily run these files, we create a new command. Using your favorite editor open a file called sbcl.run. The content should be:

    #!/bin/bash
    sbcl --noinform --load "$1" --quit --end-toplevel-options "$@"

Now you may invoke sbcl.run hello.fasl to run the native code.

    # sbcl.run hello.fasl

Details are described in the SBCL manual: Starting SBCL

Another option is to add to the runtime all packages/functions/frameworks that you commonly use, and then save this state as a new core file, and use this as your default core while continuing development. I usually find fasls more trouble than they are worth, especially since lisp has the ability to save state in a VM-style core file. I just incrementally update the core as development moves along. And rebuild/update the core using GNU Make.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!