Running a Common Lisp function from a Terminal command prompt

后端 未结 4 1176
终归单人心
终归单人心 2020-12-05 19:36

I\'m having some difficulty finding an answer to this, so maybe it isn\'t possible. I\'d like the flexibility of being able to load/compile a lisp file from a command line,

4条回答
  •  庸人自扰
    2020-12-05 20:30

    The following is a paste from the first google result:

    CLISP

    If you're using the CLISP Common Lisp environment, the following applies.

    To compile a program named test.lisp program into a bytecode file named test.fas, do the following.

    clisp -c test.lisp

    If you want less output to be shown, do the following instead.

    clisp -q -c test.lisp

    To run the compiled (or even uncompiled, if you skip the above step) Lisp file, do the following, assuming that your entry function is named main. Normally the result of the main function is shown when it's done, but the (quit) command prevents that. The -on-error abort option prevents clisp from dropping into a debugging prompt, and exits instead when there is an error.

    clisp -q -q -on-error abort -x '(progn (load "test") (main) (quit))'

    I just tested it on my arch linux terminal and you can do the following:

    $ clisp myprogram.lisp

    This will run the program right in the terminal. If you want to compile it to run later, see the above bit.

提交回复
热议问题