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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 認識Java中String與StringBuffer以及StringBuilderJavaUI
- cookie與session的區別以及在Django中的實現CookieSessionDjango
- Kotlin中的Ranges以及自定義RangeKotlin
- JS中的DOM— —節點以及操作JS
- 白話 Ruby 與 DSL 以及在 iOS 開發中的運用iOS
- numpy中np.array()與np.asarray的區別以及.tolist
- 關於對於Java中Entity以及VO,以及DTO中Request物件序列化的學習Java物件
- MySQL概述以及MySQL的安裝以及啟動MySql
- async與defer的作用與區別以及阻塞優化優化
- JS中的九個console命令以及用法JS
- Spring框架中的容器以及兩大特性Spring框架
- js中==和===的區別以及總結JS
- WebView與JS的互動,以及注意事項WebViewJS
- 棧與堆的區別以及增長方向
- Go中struct巢狀與物件導向以及上下文GoStruct巢狀物件
- PHP 中的陣列相加操作以及與 array_merge 之間的區別PHP陣列
- SpringBoot中@PropertySource和@ImportResource以及@BeanSpring BootImportBean
- JavaScript中this指向以及改變this指向JavaScript
- jquery操作radio取值以及選中jQuery
- 關於為什麼Java是單派發以及Common Lisp又偉大了一次的這檔子事JavaLisp
- jwt 實踐以及與 session 對比JWTSession
- RabbitMQ簡介以及與SpringBoot整合示例MQSpring Boot
- async與await以及巨集微任務AI
- 【轉】Lisp 已死,Lisp 萬歲!Lisp
- javascript中的this使用場景以及箭頭函式中的thisJavaScript函式
- 聊聊Grpc使用中的坑以及怎麼填RPC
- [譯] 認識 rxjs 中的 BehaviorSubject、ReplaySubject 以及 AsyncSubjectJS
- Redis 哨兵使用以及在 Laravel 中的配置RedisLaravel
- DDD中聚合、聚合根的含義以及作用
- ArrayList分析2 :Itr、ListIterator以及SubList中的坑
- Python中OS對目錄的操作以及引用Python
- Python中遍歷字典以及字典中的鍵和值Python
- vi與vim的區別以及常用命令***
- vi與vim的區別以及常用命令
- DDD興起的原因以及與微服務的關係微服務
- framework7的改進,以及與vue組合使用遇到的問題以及解決方法 (附vue的原理)FrameworkVue
- Qt中的佈局淺析與彈簧的使用,以及Qt居中的兩種方法QT
- Java環境搭建與配置、以及Tomcat搭建與配置JavaTomcat
- Flink的Table以及SQLSQL