我已经将以下方法添加到泛型函数speak中,但现在希望在不删除其他泛型函数方法的情况下删除REPL中的这个特定方法。
(defmethod speak :around ((c courtier) string) ; [1]
(format t "Does the King believe that ~A?" string)
(if (eql (read) 'yes)
(if (next-method-p) (call-next-method)) ; [2]
(format t "Indeed, it is a preposterous idea.~%"))
'bow)
[1] The :around method replaces the primary method for the type.
[2] Then it decides whether to call the primary method or not.函数文档链接 remove-method没有示例,我不知道上面引用实际:around方法的语法是什么。
(remove-method #'speak)
TOO FEW ARGUMENTS
(remove-method #'speak :around)
NO-APPLICABLE-METHOD发布于 2019-08-09 07:01:59
从文件中:
移除方法通用函数法
它需要一个泛型函数对象和一个方法对象作为参数。
通过find-method可以找到该方法。
CL-USER 39 > (find-method #'speak
(list :around)
(list (find-class 'courtier) (find-class t)))
#<STANDARD-METHOD SPEAK (:AROUND) (COURTIER T) 42001285EB>
CL-USER 40 > (remove-method #'speak
(find-method #'speak
(list :around)
(list (find-class 'courtier)
(find-class t))))
#<STANDARD-GENERIC-FUNCTION SPEAK 422000A68C>还请注意,良好的Lisp开发环境也可能允许删除编辑器或检查器中的方法。
注意,在Lisp侦听器中,不需要像上面那样两次调用find-method。变量*包含最后一个结果。
CL-USER 43 > (find-method #'speak
(list :around)
(list (find-class 'courtier)
(find-class t)))
#<STANDARD-METHOD SPEAK (:AROUND) (COURTIER T) 4200150DEB>
CL-USER 44 > (remove-method #'speak *)
#<STANDARD-GENERIC-FUNCTION SPEAK 422000A68C>下面是另一个使用GNU中的SLIME的交互示例,其中启用了SLIME的表示功能。表示是Lisp输出,它保持打印对象和生成的文本之间的连接。

调用find-method函数。它返回方法。这里我们使用presentations,它保持文本和Lisp对象之间的连接。输出以红色显示,并且是鼠标敏感的.将鼠标移动到返回的红色对象上将添加交互选项。
现在,在红色输出上键入(remove-method #'speak,然后在中间单击(或任何配置使用的黏液):表示(文本和连接的对象)将被复制到行中。键入)并输入表单。那么,粘液实际上是用真实的对象而不是文本表示来构造一个列表。
这是如何在Symbolics机器和在CLIM /McCLIM中工作的.
https://stackoverflow.com/questions/57424177
复制相似问题