变量 *、+ 和 / 是否绑定到 SLIME 或 Clozure CL 中最近的输入?

发布于 2024-09-18 01:57:01 字数 510 浏览 9 评论 0原文

当我在 SLIME(连接了 Clozure REPL)中闲逛时,我发现了这一点:

看起来变量 +、* 和 / 都绑定到最近输入的某些变化,+ 是输入本身,* 是评估的结果该输入,/ 是列表中包含的结果。

这是对的吗?谁应对此负责,SLIME 还是 Clozure?我在 SLIME 手册中找不到任何内容。

谢谢!

; SLIME 2010-05-13
CL-USER> +
NIL
CL-USER> *
NIL
CL-USER> /
(NIL)
CL-USER> -
-
CL-USER> +
-
CL-USER> (list 1 2)
(1 2)
CL-USER> +
(LIST 1 2)
CL-USER> /
((LIST 1 2))
CL-USER> (+ 1 2)
3
CL-USER> /
(3)
CL-USER> *
(3)
CL-USER> (* 1 2)
2
CL-USER> *
2
CL-USER> 

I was messing around in SLIME (connected a Clozure REPL) when I discovered this:

It looks like the variables +, *, and / are all bound to some variation on recent input, + is the input itself, * is the result of evaluating that input, and / is the result contained in a list.

Is this right? Who is responsible for this, SLIME or Clozure? I couldn't find anything in the SLIME manual.

Thanks!

; SLIME 2010-05-13
CL-USER> +
NIL
CL-USER> *
NIL
CL-USER> /
(NIL)
CL-USER> -
-
CL-USER> +
-
CL-USER> (list 1 2)
(1 2)
CL-USER> +
(LIST 1 2)
CL-USER> /
((LIST 1 2))
CL-USER> (+ 1 2)
3
CL-USER> /
(3)
CL-USER> *
(3)
CL-USER> (* 1 2)
2
CL-USER> *
2
CL-USER> 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

黑寡妇 2024-09-25 01:57:01

这些都是 Common Lisp 标准指定的。在环境字典中搜索“变量”。

Those are all, and more, specified by the Common Lisp standard. Search the environment dictionary for 'Variable'.

瀞厅☆埖开 2024-09-25 01:57:01

<代码>+
<代码>++
<代码>+++

当顶级循环评估表单时,变量 + 绑定到循环读取的前一个表单。变量 ++ 保存 + 的先前值(即,两次交互之前评估的表单),+++ 保存 ++ 的先前值。

<代码>-

当顶层循环评估表单时,变量 - 绑定到表单本身;也就是说,一旦交互完成,它就是要赋予 + 的值。

<代码>*
<代码>**
<代码>***

当顶层循环评估表单时,变量 * 绑定到最后一次循环结束时打印的结果;也就是说,它是通过评估 + 中的形式而产生的值。如果产生多个值,* 仅包含第一个值; * 如果产生零值,则包含 nil。变量**保存*之前的值(即两次交互之前打印的结果),*保存**之前的值。

<代码>/
<代码>//
<代码>///

当顶层循环评估表单时,变量 / 绑定到上次循环结束时打印的结果列表;也就是说,它是通过评估 + 中的形式生成的所有值的列表。 * 的值应始终与 / 值的汽车相同。变量 // 保存 / 的前一个值(即两次交互之前打印的结果), /// 保存 // 的前一个值。因此 ** 的值应始终与 // 的汽车相同,对于 * 和 /// 也是如此。

来自 Common Lisp 语言,第二版 20.2

+
++
+++

While a form is being evaluated by the top-level loop, the variable + is bound to the previous form read by the loop. The variable ++ holds the previous value of + (that is, the form evaluated two interactions ago), and +++ holds the previous value of ++.

-

While a form is being evaluated by the top-level loop, the variable - is bound to the form itself; that is, it is the value about to be given to + once this interaction is done.

*
**
***

While a form is being evaluated by the top-level loop, the variable * is bound to the result printed at the end of the last time through the loop; that is, it is the value produced by evaluating the form in +. If several values were produced, * contains the first value only; * contains nil if zero values were produced. The variable ** holds the previous value of * (that is, the result printed two interactions ago), and * holds the previous value of **.

/
//
///

While a form is being evaluated by the top-level loop, the variable / is bound to a list of the results printed at the end of the last time through the loop; that is, it is a list of all values produced by evaluating the form in +. The value of * should always be the same as the car of the value of /. The variable // holds the previous value of / (that is, the results printed two interactions ago), and /// holds the previous value of //. Therefore the value of ** should always be the same as the car of //, and similarly for * and ///.

From Common Lisp the Language, 2nd Edition 20.2

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文