- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我试图打开一个与我正在运行的 .lsp 文件位于同一文件夹中的文件,但它给我这个错误:错误:没有这样的文件或目录:“a.txt”
这是我使用的代码:
(defun readfile ()
(let (lines columns matrix)
(with-open-file (file "a.txt")
(setq lines (parse-integer (read-char file)))
(setq columns (parse-integer (read-char file))))))
为什么找不到文件?
最佳答案
没有找到,因为你没有说文件在哪里。您所提供的只是一个名称/类型,没有目录。
这个函数的文件在哪里并不重要。它不设置路径名的上下文。
通常情况下,像 Clozure CL 这样的东西会在默认情况下在其启动的目录中查找。
另外 Common Lisp 有一个变量 *default-pathname-defaults*
。您可以在那里设置或绑定(bind)路径名的默认值。
您对 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”(Read Eval Print Loop),而且还支持“命令”。 CCL就是这样的情况。要查看 CCL 提供的命令,请使用 :help
。在调试器中也有不同的/更多的命令。
Clozure CL 提供查找或设置当前目录的命令非常有用。其他 CL 实现提供类似的功能 - 但方式不同,因为没有针对命令机制(除了 CLIM)和默认命令的标准。
在 Mac 上的 IDE 中运行的 Clozure Common Lisp 示例:
? :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 找不到要打开的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16795603/
例如,我有一个父类Author: class Author { String name static hasMany = [ fiction: Book,
代码如下: dojo.query(subNav.navClass).forEach(function(node, index, arr){ if(dojo.style(node, 'd
我有一个带有 Id 和姓名的学生表和一个带有 Id 和 friend Id 的 Friends 表。我想加入这两个表并找到学生的 friend 。 例如,Ashley 的 friend 是 Saman
我通过互联网浏览,但仍未找到问题的答案。应该很容易: class Parent { String name Child child } 当我有一个 child 对象时,如何获得它的 paren
我正在尝试创建一个以 Firebase 作为我的后端的社交应用。现在我正面临如何(在哪里?)找到 friend 功能的问题。 我有每个用户的邮件地址。 我可以访问用户的电话也预订。 在传统的后端中,我
我主要想澄清以下几点: 1。有人告诉我,在 iOS 5 及以下版本中,如果您使用 Game Center 设置多人游戏,则“查找 Facebook 好友”(如与好友争夺战)的功能不是内置的,因此您需要
关于redis docker镜像ENTRYPOINT脚本 docker-entrypoint.sh : #!/bin/sh set -e # first arg is `-f` or `--some-
我是一名优秀的程序员,十分优秀!