找不到它,因为您没有说过该文件在哪里。你所给的只是一个名字/类型而没有目录。
其中该功能的文件无关紧要。它不为路径名设置上下文。
通常情况下,像Clozure CL会在默认情况下从它开始的目录中查找。
另外Common Lisp有一个变量*default-pathname-defaults*
。您可以在那里设置或绑定路径名的默认值。
您的CCL选项:
- 开始CCL在正确的目录
- 使用
(:cd "/mydir/foo/bar/")
将当前目录中的REPL。这是特定于CCL
- 集或绑定
*default-pathname-defaults*
您也可以计算基于您加载的源文件路径名。您需要像这样的文件:
(defvar *my-path* *load-pathname*)
(let ((*default-pathname-defaults* (or *my-path*
(error "I have no idea where I am"))))
(readfile))
顺便说一句。:经常Lisp的听众不仅包括了“REPL”的(读取 - 求值 - 输出循环),而且还支持“命令”。 CCL就是这种情况。查看CCL提供的命令使用:help
。在调试器中还有不同的/更多的命令。
Clozure CL提供命令查找或设置当前目录非常有用。其他CL实现提供了类似的功能 - 但以一种不同的方式,因为命令机制(除了CLIM)和默认命令没有标准。从Clozure Common Lisp的
示例在IDE中运行在Mac上:
? :help
The following toplevel commands are available:
:KAP Release (but don't reestablish) *LISTENER-AUTORELEASE-POOL*
:SAP Log information about current thread's autorelease-pool(s)
to C's standard error stream
:RAP Release and reestablish *LISTENER-AUTORELEASE-POOL*
:? help
:PWD Print the pathame of the current directory
(:CD DIR) Change to directory DIR (e.g., #p"ccl:" or "/some/dir")
(:PROC &OPTIONAL P) Show information about specified process <p>
/all processes
(:KILL P) Kill process whose name or ID matches <p>
(:Y &OPTIONAL P) Yield control of terminal-input to process
whose name or ID matches <p>, or to any process if <p> is null
Any other form is evaluated and its results are printed out.
什么口齿不清您使用的? (我在猜测普通的lisp)。你是否在使用Slime?(如果这样的话repl可能指向不同的目录)......总之,我们需要更多的细节!在你的问题中设置标签,你将得到更快的答案:) – Baggers
我在Mac机上使用Clozure CL。 – linkyndy
哪个是lisp进程的当前目录?你可以通过在REPL的提示符下调用'(ccl :: current-directory-name)'来找到它。什么是“a.txt”存储的目录?和完全不相关的:'(parse-integer(read-char ...))'可能是一个错误。 'parse-integer'想要一个字符串,而不是一个字符作为参数 – Dirk