Skip to content

fitzsim/cl-starter-script

Repository files navigation

This is a small Common Lisp script that can be used as a template.

To try it, first install SBCL, GNU CLISP, or ECL for your distribution, e.g., run apt install sbcl or dnf install sbcl as root.

Then, as a normal user, run:

git clone -q --recursive https://git.sr.ht/~fitzsim/cl-starter-script && \
./cl-starter-script/start.lisp --help

and you should see:

Usage: start.lisp [-h|--help] [-v|--verbose] [-l|--level LEVEL]
                  [-o|--output FILE] [REST]
Common Lisp script

Available options:
  -h, --help        print this help text
  -v, --verbose     verbose output
  -l, --level LEVEL run at LEVEL
  -o, --output FILE output to FILE

Change.

You can compile the script:

cd ./cl-starter-script
./compile.lisp
./start --help

and you should see:

Usage: start [-h|--help] [-v|--verbose] [-l|--level LEVEL] [-o|--output FILE] [REST]
Common Lisp script

Available options:
  -h, --help        print this help text
  -v, --verbose     verbose output
  -l, --level LEVEL run at LEVEL
  -o, --output FILE output to FILE

Change.

If anything doesn't work, complain by filing a todo.

Renaming

The package name is derived from the file name. To start customizing just rename the scipt:

mv start.lisp myscript.lisp
ln -sf myscript.lisp compile.lisp

It's a start...

Features:

  • Template for a small Common Lisp utility script.

  • Meant to be renamed and hacked up.

  • Runnable from the command line.

  • Loadable in a REPL.

  • SBCL, GNU CLISP and ECL support, so far.

  • Compilation support for SBCL and GNU CLISP.

  • Self-contained within the recursive checkout directory.

  • Runnable without an Internet connection after the first Git clone.

  • Command line option parsing support provided by unix-opts.

  • Experiment with no :use at all, not even :common-lisp. Interesting, but in practice :use :cl and remove cl: prefixes.

Supported Lisp Implementations as of January 2022

These are tried in order, from fastest to slowest. A cold run results from first removing the implementation's ASDF cache, for example by removing ~/.cache/common-lisp/, then running:

./start.lisp

A warm is the same command after everything is cached.

Implementation Version Cold Run (seconds) Warm Run (seconds)
SBCL 2.1.9.debian 0.579 0.579
GNU CLISP 2.49.93+ (2018-02-18) 1.159 0.871
ECL 21.2.1 3.195 1.207

Alternatives

Check out cl-launch which unfortunately is not widely packaged by distros.

Also look at Roswell as another potential basis for Common Lisp scripting and lots more.

Learning resources

A great introduction to Common Lisp; explains ASDF and Quicklisp better than anything else I've read:

A Road to Common Lisp

This PDF fosters a practical understanding of Common Lisp packges. I haven't found it available as a web page:

The Complete Idiot’s Guide to Common LispPackages

Refer to this page to set up a Common Lisp environment on a new machine:

lisp-lang.org Getting Started

Releases

No releases published

Packages

No packages published