如何执行常见的lisp文本文件(clozure cl)?

时间:2015-11-23 04:16:35

标签: common-lisp sbcl

我是Lisp的初学者,只使用DrRacket在Racket / Scheme中进行了一些涉猎。我很难找到如何使用Clozure CL for Windows运行.lisp文件。我尝试在Ubuntu上运行SBCL中的.lisp文件(在virtualbox上运行)也没有成功。

我应该提一下,我已经查看了有关运行文件的相关问题,但我无法看到任何直接的解决方案。有些人正在使用.bat文件,有些人正在使用#34;创建应用程序"使用Clozure CL的图像(或其他类似的东西)。

对于Ubuntu中的SBCL,我尝试过:

sbcl lisptest.lisp       \ The python/forth way.

(load "lisptest.lisp")

(load lisptest.lisp)

(--load lisptest.lisp)

:cd C:\Temp
(:cd C:\Temp)

等等。 我也尝试从记事本++中运行它:

cmd /k C:\Temp\ccl-1.11-windows\ccl\wx86cl64.exe "$(FULL_CURRENT_PATH)"

这是我通常执行python文件的方式,但这种方法还没有成功。

**我一定会开始学习使用Emacs和Slime(Emacs是lisp的明显选择)。但是为了知识,我会欣赏一些关于替代的基本文本编辑方式的一些技巧,这些方法可以让你得到一些微不足道的东西,例如" hello world"打印时没有我明确地输入到REPL中,而是用指令解释(或编译)文本文件。

感谢您的帮助。

2 个答案:

答案 0 :(得分:1)

通常程序有帮助 - 您是否看过它?

SBCL,Ubuntu,来自shell:

Common Lisp文件:

$ cat test.lisp
(format t "Hello World~%~%")

SBCL显示帮助:

$ sbcl --help
Usage: sbcl [runtime-options] [toplevel-options] [user-options]
Common runtime options:
  --help                     Print this message and exit.
  --version                  Print version information and exit.
  --core <filename>          Use the specified core file instead of the default.
  --dynamic-space-size <MiB> Size of reserved dynamic space in megabytes.
  --control-stack-size <MiB> Size of reserved control stack in megabytes.

Common toplevel options:
  --sysinit <filename>       System-wide init-file to use instead of default.
  --userinit <filename>      Per-user init-file to use instead of default.
  --no-sysinit               Inhibit processing of any system-wide init-file.
  --no-userinit              Inhibit processing of any per-user init-file.
  --disable-debugger         Invoke sb-ext:disable-debugger.
  --noprint                  Run a Read-Eval Loop without printing results.
  --script [<filename>]      Skip #! line, disable debugger, avoid verbosity.
  --quit                     Exit with code 0 after option processing.
  --non-interactive          Sets both --quit and --disable-debugger.
Common toplevel options that are processed in order:
  --eval <form>              Form to eval when processing this option.
  --load <filename>          File to load when processing this option.

User options are not processed by SBCL. All runtime options must
appear before toplevel options, and all toplevel options must
appear before user options.

For more information please refer to the SBCL User Manual, which
should be installed along with SBCL, and is also available from the
website <http://www.sbcl.org/>.

使用上面的脚本选项:

$ sbcl --script test.lisp
Hello World

Clozure CL也是如此

$ ccl --help
usage: ccl <options>
     where <options> are one or more of:
        -h, --help : this text
        -V, --version : print (LISP-IMPLEMENTATION-VERSION) and exit
        -K, --terminal-encoding : specify character encoding to use for *TERMINAL-IO*
        -n, --no-init : suppress loading of init file
        -e, --eval : evaluate <form> (may need to quote <form> in shell)
        -l, --load : load <file>
        -T, --set-lisp-heap-gc-threshold : set lisp-heap-gc-threshold to <n>
        -Q, --quiet : if --batch, also suppress printing of heralds, prompts
    -R, --heap-reserve <n>: reserve <n> (default: 1610612736)
         bytes for heap expansion
    -S, --stack-size <n>: set  size of initial thread's control stack to <n>
    -Z, --thread-stack-size <n>: set default size of first (listener)  thread's stacks based on <n>
    -b, --batch: exit when EOF on *STANDARD-INPUT*
    --no-sigtrap : obscure option for running under GDB
    --debug : try to ensure that kernel debugger uses a TTY for I/O
    -I, --image-name <image-name>
     and <image-name> defaults to ccl.image

    Any arguments following the pseudoargument "--" are
    not processed and are available to the application as
    the value of CCL:*UNPROCESSED-COMMAND-LINE-ARGUMENTS* .

使用上面的加载选项

$ ccl --load test.lisp --eval '(quit)'
Hello World

答案 1 :(得分:0)

 试试

(load "lisptest.lisp")

这应该与

相同
{{1}}

如果您能够让我们具体了解失败的原因,我们可以提供更多帮助。