##x2B;#. 是什么意思?是什么意思?

发布于 2024-11-03 05:12:57 字数 266 浏览 0 评论 0原文

谷歌几乎是不可能的,因此我的理解仅限于阅读 slime 源代码的上下文线索:也许它是 common lisp 中对象系统的一部分?类似“自己”的东西?

片段:

(cond #+#.(swank-backend::sbcl-with-new-stepper-p)

也许这会让它更容易被谷歌搜索到: pound plus pound // hash plus hash symbol // octothorp plus octothorp

It is almost impossible to google, hence my understanding is limited to contextual clues from reading through the slime source code: perhaps it is part of the object system in common lisp? Something like 'self'?

snippet:

(cond #+#.(swank-backend::sbcl-with-new-stepper-p)

Perhaps this will make it more googleable : pound plus pound // hash plus hash symbol // octothorp plus octothorp

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

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

发布评论

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

评论(5

不交电费瞎发啥光 2024-11-10 05:12:57

这是非常罕见的。

#+clim clim:+red+ #-clim mygraphics:+red+

上面表示读取器返回红色符号,这取决于功能 *features* 列表中是否存在名为 CLIM 的符号。这是 Common Lisp 中的内置机制。

#.(cl:if (cl:zerop (cl:random 2)) :high :low)

以上也是读者的一个机制。它允许在读取时进行计算。顺便说一句。是一个安全问题,在 Lisp 应用程序中应该禁用它 - 请参阅变量 *read-eval* 来控制它。在读取时,使用 READ 的读取器将随机返回 :HIGH 或 :LOW。

组合 #+#.(FOO) BAR 表示函数 foo 在读取时返回一个符号,然后读取器将检查该符号是否在功能列表中存在具有该名称的符号 < code>*features* 如果是这种情况,则读取输入中的下一项,否则跳过下一项。

简单的示例,在此示例中 IF 始终返回 :CAPI:

在 LispWorks 中(其中 CAPI 位于功能列表中):

CL-USER 41 > (read-from-string "#+#.(cl:if cl:t :capi :clim) a b")
A
31

在 SBCL 中

* (read-from-string "#+#.(cl:if cl:t :capi :clim) a b")

B
32

That's pretty rare to see.

#+clim clim:+red+ #-clim mygraphics:+red+

above means that the reader returns either red symbol and it depends whether there is a symbol with the name CLIM is on the list of features *features*. That's a built-in mechanism in Common Lisp.

#.(cl:if (cl:zerop (cl:random 2)) :high :low)

Above also is a mechanism of the reader. It allows to do computations at read time. Which btw. is a security problem and in Lisp applications it should be disabled - see the variable *read-eval* for controlling this. At read time the reader using READ will return either :HIGH or :LOW, randomly.

The combination #+#.(FOO) BAR means that the function foo returns a symbol at read time and this symbol then is checked by the reader if there is a symbol with this name on the feature list *features* and if that is the case, then the next item in input is read, otherwise the next item is skipped over.

Trivial example, IF always returns :CAPI in this example:

In LispWorks (where CAPI is on the features list):

CL-USER 41 > (read-from-string "#+#.(cl:if cl:t :capi :clim) a b")
A
31

In SBCL

* (read-from-string "#+#.(cl:if cl:t :capi :clim) a b")

B
32
残龙傲雪 2024-11-10 05:12:57

它实际上是 Sharpsign Plus 后跟 Sharpsign 点

It's actually Sharpsign Plus followed by Sharpsign Dot.

勿忘初心 2024-11-10 05:12:57

它们是 Common Lisp阅读器宏字符

引入的文本符号
调度一两个字符
定义使用的特殊用途语法
由 Lisp 读者编写,那就是
由读取器宏实现
功能。

阅读器宏不应与常规宏混淆 - 它们彼此无关。

set-dispatch-macro-character 函数可用于通过自定义读取器宏来扩展 Common Lisp 语法。

They're Common Lisp reader macro characters:

a textual notation introduced by
dispatch on one or two characters that
defines special-purpose syntax for use
by the Lisp reader, and that is
implemented by a reader macro
function.

Reader macros should not be confused with regular macros - they have nothing to do with each other.

The set-dispatch-macro-character function can be used to extend the Common Lisp syntax with custom reader macros.

最笨的告白 2024-11-10 05:12:57

此外,仅当 foo 不在 *features* 中时,#-foo(code toexecute) 才会执行代码。

即使在 Common Lisp HyperSpec,但相关的 HyperSpec 页面可以通过 Google 搜索“Sharpsign minus”等找到。(感谢 Austin。)

Also, #-foo(code to execute) will execute the code only if foo is not in *features*.

Information about #+, #., etc. is difficult to find even in the Common Lisp HyperSpec, but relevant HyperSpec pages can be found by Googling "Sharpsign minus", etc. (Thanks Austin.)

烙印 2024-11-10 05:12:57

2.4.8.17 锐标加号
http://www.lispworks.com/documentation/HyperSpec/Body/02_dhq.htm
#+测试表达式
Readtime宏,如果测试为真则读取表达式,否则将其读取为空白。

2.4.8.6 锐号点
http://www.lispworks.com/documentation/HyperSpec/Body/02_dhf.htm
这 #。 foo 语法执行 foo 的读取时评估。

http://www.lispworks.com/documentation/HyperSpec/Body/02_dh.htm
所有 #X 运算符(由 Lisp HyperSpec 定义)

为什么 Lisp HyperSpec 必须如此难以阅读?
可能是因为它是由委员会完成的。我说这是 Lisp 不受欢迎的原因之一。另外,Lisp 太学术化了,进入门槛太高(学习曲线和支持社区不是很好......没有 10000 个小程序可以轻松入门(在一些神秘的领域)您正在使用的实现))。

2.4.8.17 Sharpsign Plus
http://www.lispworks.com/documentation/HyperSpec/Body/02_dhq.htm
#+test expression
Readtime macro, if test is true read expression, otherwise read it as white space.

2.4.8.6 Sharpsign Dot
http://www.lispworks.com/documentation/HyperSpec/Body/02_dhf.htm
The #. foo syntax performs a read-time evaluation of foo.

http://www.lispworks.com/documentation/HyperSpec/Body/02_dh.htm
All the #X operators (defined by the Lisp HyperSpec)

Why does the Lisp HyperSpec have to be so hard to read?
Probably because it's done by committee. I say it's one of the reasons Lisp is not popular. Also, Lisp is too academic, and the barriers-to-entry are too high (the learning curve and support community are not so great... there aren't 10 thousand little programs out there to easily get you started (in some arcane implementation you are using)).

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