lisp - 无法在Windows上加载.lisp文件

时间:2016-02-03 15:18:53

标签: windows common-lisp clisp

我在Windows 7上使用clisp 2.49。我启动命令窗口并导航到包含.lisp文件的目录。然后我运行clisp并尝试加载该文件。我收到错误"没有名称为C&#34的包裹;在上面。在这种情况下,C指的是驱动器C,因为填充的绝对路径以C:/../../ lispFile开头。我也试过在Allegro CL上加载文件但是得到了同样的错误。

以下是错误消息的屏幕截图。

error message

编辑: 我已经确定导致错误消息的代码行是:

(defparameter c:\\workdir\\aima\\ (truename "~/public_html/code/"); 
   "The root directory where the code is stored.")

我不确定语法是否不正确。

解决:我弄清楚我做错了什么。我得到了修改lisp文件的说明,但误解了它并替换了该行的错误部分。这是更正的代码行。

(defparameter *aima-root* (truename "c:\\workdir\\aima\\"); 
   "The root directory where the code is stored.")

1 个答案:

答案 0 :(得分:2)

请注意,还可以在加载时计算目录:

(defparameter *aima-root* 
  (when *load-pathname*
    (make-pathname :defaults *load-pathname*
                   :name nil
                   :type nil))
   "The root directory where the code is stored.")

*load-pathname*是标准的Common Lisp变量,将在加载时绑定到类似于load函数的路径名。因此它指向正在加载的文件。然后,我们构造一个新的路径名,默认值来自加载路径名,没有名称和路径名类型组件。

因此,您可以根据该计算设置*aima-root*变量,无论何时加载文件,都将计算正确的目录。

在加载时间内绑定了两个Common Lisp变量*load-pathname**load-truename*。后者是文件的真实物理路径名。通常我更喜欢使用*load-pathname*,它可能与物理路径名结构无关。这里的代码使用函数truename,因此可能需要使用*load-truename*。 Common Lisp实现通常通过存储路径名来记录定义函数和其他内容的位置。使用路径名有时比使用truename更容易找到文件 - 因为它可以使用逻辑路径名来实现与设备/机器无关的间接。

相关问题