Lisp 定义我自己的读取宏
在公共Lisp中有一些读取宏,例如Lisp 定义我自己的读取宏,lisp,common-lisp,reader-macro,Lisp,Common Lisp,Reader Macro,在公共Lisp中有一些读取宏,例如'#'#p,但是如何编写读取宏呢 像这样: #T"hello world" ====================> (gettext "hello world") 您可以在以下情况下使用和,例如: (set-dispatch-macro-character #\# #\T (lambda (s c n) `(gettext ,(read s t nil t)))) ==> T 您可以使用已安装的读取语法 (read-from-st
'
#'
#p
,但是如何编写读取宏呢
像这样:
#T"hello world"
====================>
(gettext "hello world")
您可以在以下情况下使用和,例如:
(set-dispatch-macro-character #\# #\T
(lambda (s c n)
`(gettext ,(read s t nil t))))
==> T
您可以使用已安装的读取语法
(read-from-string "#T\"this is a test\"")
==> (GETTEXT "this is a test")