- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我需要一些帮助来理解以下代码的执行顺序。
我创建了一个 pie
的实例,使用以下内容:
(cook (make-instance 'pie))
我知道 lisp 从最具体到最不具体的顺序执行函数。但是,它看起来不像是在 (defmethod cook ((p pie))
之后被遵循的。叫做。
我假设 (defmethod cook :after ((f food))
& (defmethod cook :after ((p pie))
以相反的顺序执行,因为我们的实例是 pie
,而不是父类,food
.
谢谢,任何输入将不胜感激。
(defclass food () ())
(defmethod cook :before ((f food))
(print "A food is about to be cooked."))
(defmethod cook :after ((f food))
(print "A food has been cooked."))
(defclass pie (food)
((filling :accessor pie-filling
:initarg :filling
:initform 'apple)))
(defmethod cook ((p pie))
(print "Cooking a pie.")
(setf (pie-filling p) (list 'cooked (pie-filling p))))
(defmethod cook :before ((p pie))
(print "A pie is about to be cooked."))
(defmethod cook :after ((p pie))
(print "A pie has been cooked."))
(setq pie-1 (make-instance 'pie :filling 'apple))
输出如:
"A pie is about to be cooked."
"A food is about to be cooked."
"Cooking a pie."
"A food has been cooked."
"A pie has been cooked."
(COOKED APPLE)
最佳答案
参见 section 7.6.6.2 (Standard Method Combination) of the Common Lisp HyperSpec .这是最相关的段落:
The before methods are run in most-specific-first order while the after methods are run in least-specific-first order. The design rationale for this difference can be illustrated with an example. Suppose class C1 modifies the behavior of its superclass, C2, by adding before methods and after methods. Whether the behavior of the class C2 is defined directly by methods on C2 or is inherited from its superclasses does not affect the relative order of invocation of methods on instances of the class C1. Class C1's before method runs before all of class C2's methods. Class C1's after method runs after all of class C2's methods.
关于lisp - ( :before/:after) method invocation in CLOS? 的顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8371820/
为什么Intellij会给出这个警告,这是什么意思,我怎样才能让它变得更好? import akka.actor.Props object Router { def props(config: C
我在两个类中使用react-native-image picker和react-native-image-crop picker库。 一个是启动库图像(react-native-image picke
晚上好, 我刚开始使用 Microsoft.Contracts(最新版本)并将其插入示例界面之上,现在它看起来像这样: namespace iRMA2.Core.Interfaces { us
我尝试制作用于 Symfony 2 上传的 ajax 脚本。Chrome 返回此错误: Uncaught TypeError: Illegal invocation jquery.min.js:4 我
我正在尝试在 java 中运行一些 javascript。我不确定脚本是否正确,我想在一段时间后终止调用。这就是我运行脚本的方式。 returnMethod = invocableEngine.inv
我正在为一个服务类编写 Spock 测试,该服务类的方法在 spring boot 应用程序中调用 Dao 类中的另一个方法。但是,我得到: Too few invocations for: 1
我们正在运行一个 Create React App (CRA) Web 应用程序,我们已向其中添加了 Google Analytics v4。我们使用 ga-4-react 启动分析npm 包。 in
我想将多个图像对象发布到 testphp.php。但控制台打印错误说非法调用。 我已经尝试过: submit $("#sub").click(function(){ // get th
当文本框为空时尝试禁用按钮时,我在 google chrome 控制台中收到此错误: function isEmpty() { var r = document.getElementById;
这是 html 这是脚本 $('#submit').click(function() { var files = $("[type='file']")[0].fil
我尝试通过ajax提交表单,下面是表单。 Date Upload File
我想弄乱 Speech Recognition API,所以我从简单的页面开始,该页面在单击 body 元素时开始识别。我的 scripts.js 文件是: var recognition = new
我在 Google 上进行了搜索,也浏览了 Stack 上提供的一系列类似问题,但不幸的是没有一个能帮助我解决问题。 下面是我正在做的事情,我从主视图调用 PartialView,但我的 Partia
已关闭。此问题需要 debugging details 。目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and the
为简单起见,我们来看一个非常简单的类: public class TestingClass { public void method1(){ System.out.printl
编辑:到目前为止建议的答案都不起作用。 我正在使用 django 运行此调用。第一次运行时,服务器返回“n_usr”(这会更改用户文件的形式)。第二次,它只是抛出一个非法调用错误。 function
每当我必须使用 gcloud 部署新的 python 函数时sdk 我收到这条消息 Allow unauthenticated invocations of new function [functio
这个问题已经有答案了: getUserMedia() in JavaScript normalizes across browsers. Illegal Invocation (1 个回答) 已关闭
我试图通过发布一些 xml 来登录来测试登录 Web 服务,但它再次出现此错误: 未捕获的类型错误:非法调用 这是代码: $(document).ready(function() { var da
function submit() { console.log('Submit!'); } function foo(callback, param) { console.log(ca
我是一名优秀的程序员,十分优秀!