我是一个lisp noob尝试使用sbcl v1.0.50学习lisp.
我正在编写一个简单的记录器并遇到一个我不理解的内存故障,但这似乎与我编译脚本的方式有关.我把它归结为以下内容:
=== logger.lisp ===
(defparameter *log-stream* (open "/tmp/global-log"
:direction :output
:if-does-not-exist :create
:if-exists :append))
Run Code Online (Sandbox Code Playgroud)
=== main.lisp ===
(load "logger.lisp")
(defun main ()
(format *log-stream* "Hello world~%"))
Run Code Online (Sandbox Code Playgroud)
== == compile.lisp
#! /usr/bin/sbcl --script
(load "main.lisp")
(save-lisp-and-die "program" :toplevel #'main :executable t)
Run Code Online (Sandbox Code Playgroud)
当我编译并运行程序时,它会崩溃:
> ./compile.lisp
[undoing binding stack and other enclosing state... done]
[saving current Lisp image into foo:
writing 6352 bytes from the read-only space at 0x20000000
writing 4064 bytes from the static space at 0x20100000
writing 43057152 …Run Code Online (Sandbox Code Playgroud)