Difference between revisions of "Agent problems"
m |
Colin-adams (Talk | contribs) m (Corrected typo from B to C) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | [[Category:ECMA]] | ||
+ | {{UnderConstruction}} | ||
+ | |||
The following feature expects as its formal argument an agent: | The following feature expects as its formal argument an agent: | ||
Line 6: | Line 9: | ||
l_f: FUNCTION [A, TUPLE, C] | l_f: FUNCTION [A, TUPLE, C] | ||
do | do | ||
+ | l_f := f | ||
Result := l_f.item ([]) | Result := l_f.item ([]) | ||
end | end | ||
Line 13: | Line 17: | ||
* refer to a feature of a descendant of class A. | * refer to a feature of a descendant of class A. | ||
* have at least one open argument. The type of it needs to be a descendant of class B. | * have at least one open argument. The type of it needs to be a descendant of class B. | ||
− | * refer to a feature with a return type that is a descendant of class | + | * refer to a feature with a return type that is a descendant of class C. |
At the same time feature foo gives almost no guarantees about how it will use agent f. It calls the agent without passing any arguments. This is not detected by the type system but will certainly end in runtime failures. This is a very unfortunate situation. The Eiffel agent mechanism is quite verbose, the user has to type in a lot of typing information. At the same time the type system gives the programmer no safety. | At the same time feature foo gives almost no guarantees about how it will use agent f. It calls the agent without passing any arguments. This is not detected by the type system but will certainly end in runtime failures. This is a very unfortunate situation. The Eiffel agent mechanism is quite verbose, the user has to type in a lot of typing information. At the same time the type system gives the programmer no safety. |
Latest revision as of 04:30, 11 April 2007
The following feature expects as its formal argument an agent:
foo (f: FUNCTION [A, TUPLE [B], C]): C local l_f: FUNCTION [A, TUPLE, C] do l_f := f Result := l_f.item ([]) end
By giving its formal argument a type, a feature specifies what it expects of the actual arguments. Feature foo expects the passed agent to:
- refer to a feature of a descendant of class A.
- have at least one open argument. The type of it needs to be a descendant of class B.
- refer to a feature with a return type that is a descendant of class C.
At the same time feature foo gives almost no guarantees about how it will use agent f. It calls the agent without passing any arguments. This is not detected by the type system but will certainly end in runtime failures. This is a very unfortunate situation. The Eiffel agent mechanism is quite verbose, the user has to type in a lot of typing information. At the same time the type system gives the programmer no safety.