CLISP 的 REPL 中有哪些神奇变量?
我注意到,当我在 REPL 中键入运算符时,它通常会扩展为与输入/输出历史记录有关的值。
具体来说,我注意到:
+
,++
...扩展到以前的输入,*
,**
。 .. 扩展到以前的输出,-
扩展到当前输入
显然还有更多( /
扩展到某些内容,但我还没有完全弄清楚)。
我尝试浏览 clisp 文档,但没有成功。
我的问题:
- 还有哪些神奇的 REPL 变量?他们做什么?
- 有没有办法访问第 N 个输入或输出(如 IPython 的 In 和 Out 数组)?
I have noticed that when I type an operator in REPL, it is often expanded into a value which has something to do with the input/output history.
Specifically I noticed that:
+
,++
... expand to previous inputs,*
,**
... expand to previous outputs,-
expand to the current input
There apparently are more (/
expands to something but I haven't figured it out exactly).
I've tried browsing the clisp docs, but unsuccessfully.
My questions:
- What such magic REPL variables are also there? What do they do?
- Is there a way to access Nth input or output (like IPython's
In
andOut
arrays)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
REPL 变量记录在 Hyperspec 的环境字典中(搜索“多变的”)。该标准不需要保留三个以上的输入/输出,而且我不知道有任何实现可以做到这一点。
The REPL variables are documented in the environment dictionary of the Hyperspec (search for "Variable"). The standard does not require holding any more of input/outputs than three, and I am not aware of any implementation that does it.
正如另一个答案中提到的,这些变量记录在 ANSI Common Lisp 标准中。
除此之外,Common Lisp 实现可能还有许多其他功能。具有用户界面的全功能顶层通常称为“Lisp 监听器”。
CLISP 实现在调试器中提供了附加命令。请参阅其文档的第 25 章。
LispWorks 在 REPL 中有一些扩展,还提供了 监听器。以下是一些示例:
交互编号 2,在 CL-USER 包中:
相同,但我们可以省略外括号:
让我们重做交互 2:
让我们重做交互 2,但用除法而不是乘法:
具有命令等扩展的其他实现、输出历史记录或类似功能例如 Allegro CL 和 Clozure CL。
SLIME 提供了基于 GNU Emacs 的 Common Lisp 开发环境,还提供了扩展的 REPL。
As mentioned in the other answer, these variables are documented in the ANSI Common Lisp standard.
In addition to that a Common Lisp implementation may have lots of other features. A full featured top-level with user interface is often called a 'Lisp listener'.
The CLISP implementation provides additional commands in the debugger. See chapter 25 of its documentation.
LispWorks has some extensions in the REPL and also provides a Listener. Here are some examples:
Interaction number 2, in the CL-USER package:
The same, but we can omit the outer parentheses:
Let's redo interaction 2:
Let's redo interaction 2, but with division instead of multiplication:
Other implementations with extensions like commands, output histories, or similar features are for example Allegro CL and Clozure CL.
SLIME, which provides a Common Lisp development environment based on GNU Emacs, also provides an extended REPL.