5
Common Lisp中有一些读取宏,如'
#'
#P
,但是我该如何编写读取宏?定义我自己的读取宏
像这样:
#T"hello world"
====================>
(gettext "hello world")
Common Lisp中有一些读取宏,如'
#'
#P
,但是我该如何编写读取宏?定义我自己的读取宏
像这样:
#T"hello world"
====================>
(gettext "hello world")
您可以使用set-macro-character和set-dispatch-macro-character之后,例如:
(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")