Writing Common Lisp code that executes from the command line, but not inside the interpreter

后端 未结 3 1819
甜味超标
甜味超标 2020-12-30 09:17

When writing Common Lisp code, I use SLIME. In particular, I compile the buffer containing definitions of functions by using C-C C-k, and then switch to the REPL to run thos

3条回答
  •  攒了一身酷
    2020-12-30 09:26

    Fare Rideau wrote a nifty unix utility CL-Launch, which enables executing lisp software from the command line. It has integrated Quicklisp support and works on most of the Common Lisp implementations.

    Example script may look like this:

    #!/usr/bin/cl -sp "hunchentoot" -Q -E main
    
    (defun main (argv)
      (format t "~A: ~{~A ~}~%" (truename ".") argv)
      (hunchentoot:start
       (make-instance 'hunchentoot:acceptor
                      :document-root (truename ".")
                      :port 8080))
      (do ((x #\s (read-char)))
          ((char-equal x #\q) nil)))
    

    After adding +x permissions to script and invoking it, it will start http server in the current directory. "-sp" flag indicates package you want to load, so it's fairly clean way of abstracting shell script from the package.

    For more details refer: http://cliki.net/CL-Launch

提交回复
热议问题