Eiffel:一种在另一个函数上调用前体重新定义特征的方法
Eiffel: a way to call precursor redefined feature on another function
我正在寻找一种方法来调用 Precursor
另一个功能。上下文是我重新定义了一个调用另一个继承人的功能的例程,该功能调用了我的功能,我想明确地调用它。有没有办法做一些事情,比如 java Precursor.feature_a
。
如果不是,我发现唯一的选择是编写一个feature_a_implementation
并从重新定义的功能中调用它。是否有特殊原因不具有此机制?这样做的后果是将 feature_a
的合同定义为 feature_a
和 feature_a_implementation
的 2 倍
功能复制可用于:
class A feature
f do print ("A") end
end
class B inherit
A redefine f select f end
A rename f as g end
feature
f do print ("B") end
h do g end
end
class A
的特征 f
在 class B
中出现两次:在名称 f
下(重新定义和选择的版本)并在名称 g
下(原始版本)。功能 h
调用 g
并按预期打印 A
。
我正在寻找一种方法来调用 Precursor
另一个功能。上下文是我重新定义了一个调用另一个继承人的功能的例程,该功能调用了我的功能,我想明确地调用它。有没有办法做一些事情,比如 java Precursor.feature_a
。
如果不是,我发现唯一的选择是编写一个feature_a_implementation
并从重新定义的功能中调用它。是否有特殊原因不具有此机制?这样做的后果是将 feature_a
的合同定义为 feature_a
和 feature_a_implementation
功能复制可用于:
class A feature
f do print ("A") end
end
class B inherit
A redefine f select f end
A rename f as g end
feature
f do print ("B") end
h do g end
end
class A
的特征 f
在 class B
中出现两次:在名称 f
下(重新定义和选择的版本)并在名称 g
下(原始版本)。功能 h
调用 g
并按预期打印 A
。