##x2B;#. 是什么意思?是什么意思?
谷歌几乎是不可能的,因此我的理解仅限于阅读 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这是非常罕见的。
上面表示读取器返回红色符号,这取决于功能
*features*
列表中是否存在名为 CLIM 的符号。这是 Common Lisp 中的内置机制。以上也是读者的一个机制。它允许在读取时进行计算。顺便说一句。是一个安全问题,在 Lisp 应用程序中应该禁用它 - 请参阅变量
*read-eval*
来控制它。在读取时,使用 READ 的读取器将随机返回 :HIGH 或 :LOW。组合
#+#.(FOO) BAR
表示函数 foo 在读取时返回一个符号,然后读取器将检查该符号是否在功能列表中存在具有该名称的符号 < code>*features* 如果是这种情况,则读取输入中的下一项,否则跳过下一项。简单的示例,在此示例中 IF 始终返回 :CAPI:
在 LispWorks 中(其中 CAPI 位于功能列表中):
在 SBCL 中
That's pretty rare to see.
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.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):
In SBCL
它实际上是 Sharpsign Plus 后跟 Sharpsign 点。
It's actually Sharpsign Plus followed by Sharpsign Dot.
它们是 Common Lisp阅读器宏字符:
阅读器宏不应与常规宏混淆 - 它们彼此无关。
set-dispatch-macro-character 函数可用于通过自定义读取器宏来扩展 Common Lisp 语法。
They're Common Lisp reader macro characters:
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.
此外,仅当 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.)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)).