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.
[`] 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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- cookie與session的區別以及在Django中的實現CookieSessionDjango
- Mongodb中replicaset的搭建以及部署MongoDB
- Scala中的包以及包物件物件
- 指標 與 陣列 以及 a 與 &a的區別指標陣列
- JS中的DOM— —節點以及操作JS
- Android中Parcel的分析以及使用Android
- numpy中np.array()與np.asarray的區別以及.tolist
- 白話 Ruby 與 DSL 以及在 iOS 開發中的運用iOS
- Android中 @和?區別以及?attr/**與@style/**等的區別Android
- 1程式與執行緒以及Linux中fork()的運用執行緒Linux
- Mysql中varchar與char的區別以及varchar(30)中的30代表的涵義MySql
- 關於對於Java中Entity以及VO,以及DTO中Request物件序列化的學習Java物件
- SSL與TLS的區別以及介紹TLS
- $.ajax 與 $.post 的區別,以及$.post的bug
- Kotlin中的Ranges以及自定義RangeKotlin
- js中==和===的區別以及總結JS
- Java中的偽共享以及應對方案Java
- ios中Runtime的介紹以及使用iOS
- 七個Swift中的陷阱以及避免方法Swift
- JavaScript 中 this 的工作原理以及注意事項JavaScript
- JavaScript中this的工作原理以及注意事項JavaScript
- Swift 中的 7 個陷阱以及如何避免Swift
- Python中的 List Comprehension 以及 GeneratorPython
- mybatis中的mapper介面檔案以及example類的例項函式以及詳解MyBatisAPP函式
- MySQL概述以及MySQL的安裝以及啟動MySql
- JavaScript中this指向以及改變this指向JavaScript
- async與defer的作用與區別以及阻塞優化優化
- WebView與JS的互動,以及注意事項WebViewJS
- 棧與堆的區別以及增長方向
- Jetty 的工作原理以及與 Tomcat 的比較JettyTomcat
- javascript中的this使用場景以及箭頭函式中的thisJavaScript函式
- Redis 哨兵使用以及在 Laravel 中的配置RedisLaravel
- ArrayList分析2 :Itr、ListIterator以及SubList中的坑
- Spring框架中的容器以及兩大特性Spring框架
- SQL server 中SUBSTRING()以及CONVERT()的用法SQLServer
- group by中rollup的以及grouping含義解析
- Scala中的單例以及鏈式表示式單例
- jwt 實踐以及與 session 對比JWTSession