linux lisp,lisp 中的 【,@】 与 【·】 以及【‘】 以及【 。,】

我们经常在宏定义中看到这个 ,@body

[`] back quator   (大键盘 数字键 1 左边的那个键)

以及

【‘】 单引号

以及

【。,body】  (句号后面跟个逗号, cons  返回的那个格式)

示例:

(setf test1 '(a test))

(A TEST)

CL-USER> `(this is ,test1)

(THIS IS (A TEST))

CL-USER> `(this is ,@test1)

(THIS IS A TEST)

CL-USER> `(this is . ,test1)

(THIS IS A TEST)

CL-USER> `(this is ,@test1 -- this is only .,test1)

(THIS IS A TEST -- THIS IS ONLY A TEST)

英文原文记录如下:

The need to build up code (and noncode data) from components is so frequent that

there is a special notation for it, the backquote notation. The backquote character

" ' " is similar to the quote character " ' ". A backquote indicates that what follows is

mostly a literal expression but may contain some components that are to be evaluated.

Anything marked by a leading comma " , " is evaluated and inserted into the structure,

and anything marked with a leading " , @" must evaluate to a list that is spliced into

the structure: each element of the list is inserted, without the top-level parentheses.

The notation is covered in more detail in section 23.5. Here we use the combination

of backquote and comma to rewrite whi 1 e:

(defmacro while ( t e s t &rest body)

"Repeat body while t e s t i s t r u e ."

'(loop (unless , t e s t ( r e t u r n n i l ) )

,@body)

Here are some more examples of backquote. Note that at the end of a list, " , @ " has the

same effect as " . " followed by " , " . In the middle of a list, only " , @" is a possibility.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/133735/viewspace-764268/,如需转载,请注明出处,否则将追究法律责任。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值