【发布时间】:2013-05-26 21:34:50
【问题描述】:
我一直在阅读 Peter Seibel Practical Common Lisp 的优秀书籍,以解决我一直在做的与 Common Lisp 错误处理系统相关的一些研究。
虽然我看了书上的解释,也试着在网上挖了一些资料,但我一直无法理解STORE-VALUE和USE-VALUE重启的含义和用法。有人能解释一下这些函数的目的是什么吗?
;;; Example of the STORE-VALUE and USE-VALUE restarts
(defun careful-symbol-value (symbol)
(check-type symbol symbol)
(restart-case (if (boundp symbol)
(return-from careful-symbol-value
(symbol-value symbol))
(error 'unbound-variable
:name symbol))
(use-value (value)
:report "Specify a value to use this time."
value)
(store-value (value)
:report "Specify a value to store and use in the future."
(setf (symbol-value symbol) value))))
【问题讨论】:
标签: exception-handling error-handling lisp common-lisp condition-system