首页 > 解决方案 > 如何禁用阅读器宏?

问题描述

我使用本地时间的阅读器宏,直到我意识到我不需要它(想读回日期?只需使用格式或本地时间:格式日期字符串,它不会输出@...)。

但是,它与使用 Parenscript 代码冲突ps:@

冒号后的非法终止字符:#@

我可以在不重新启动图像的情况下禁用阅读器宏吗?

它的作用是

(defun enable-read-macros ()
  "Enables the local-time reader macros for literal timestamps and universal time."
  (set-macro-character #\@ '%read-timestring)
  (set-dispatch-macro-character #\# #\@ '%read-universal-time)
  (values))

我没有在 Parenscript 方面看到阅读器宏。

标签: common-lispreader-macro

解决方案


也许您可以做的是尝试使用类似这样的方法将更改还原到当前可读表,这应该会获得标准可读表并将当前可读表的条目“恢复”为标准表。

(let ((rt (copy-readtable nil)))
  (multiple-value-bind (function non-terminating-p)
      (get-macro-character #\@ rt)
    (set-macro-character #\@ function non-terminating-p))
  (set-dispatch-macro-character #\# #\@ (get-dispatch-macro-character #\# #\@ rt)))

推荐阅读