Lisp 中照应条件句的例子是什么?
Lisp 中照应条件句的例子是什么?还请解释一下代码。
What would be an example of an anaphoric conditional in Lisp? Please explain the code as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Paul Graham 的 On Lisp 有一章介绍 照应宏。
本质上,它是一种编写语句的速记方式,可以避免重复代码。例如,compare:
and
其中
it
是一个特殊名称,指的是(big-long-calculation)
中刚刚计算的内容。Paul Graham's On Lisp has a chapter on Anaphoric Macros.
Essentially, it's a shorthand way of writing statements that avoids repeating code. For example, compare:
and
where
it
is a special name that refers to whatever was just calculated in(big-long-calculation)
.Common Lisp
LOOP
就是一个例子:变量
IT
具有测试表达式的值。这是 ANSI Common LispLOOP
工具的一个功能。示例:
返回,
因为只有
"SIN"
是现有符号的名称,此处为符号SIN
。在 Common Lisp 中,符号名称默认具有内部大写名称。An example is the Common Lisp
LOOP
:The variable
IT
has the value of the test expression. This is a feature of the ANSI Common LispLOOP
facility.Example:
returns
because only
"SIN"
is a name for an existing symbol, here the symbolSIN
. In Common Lisp symbol names have internally uppercase names by default.