![]() |
|
|
|
|
|
|
7
4th October 18:05
External User
Posts: 1
|
In this message I will use "SmartEiffel's implementation" and
"ISE's implementation" instead of "covariance/contravariance" or "reverse conformance" in order to avoid a terminology war. The problem with SmartEiffel's implementation is that (2) is not just "open arguments" but "open operands", in other words the target can also be open. Let's consider the following classes: class ANIMAL feature eat (f: FOOD) is do ... end end class COW inherit ANIMAL redefine eat end feature eat (f: GRASS) is do ... end ... end Now let's have this routine: do_something (p: PROCEDURE [ANY, TUPLE [COW]]) is local my_cow: COW do create my_cow p.call ([my_cow]) end In SmartEiffel's implementation it is valid to write: create meat do_something (agent {ANIMAL}.eat (meat)) ending up trying to make a cow eat some meat at run-time. ISE's implementation rejects this code at compilation time. That was with an open target. Now with open arguments let's have this other routine: do_something_else (p: PROCEDURE [ANY, TUPLE [FOOD]]) is local my_meat: MEAT do create my_meat p.call ([my_meat]) end In ISE's implementation it is valid to write: create cow do_something_else (agent cow.eat) ending up trying to make a cow eat meat at run-time. SmartEiffel's implementation rejects this code at compilation time. In defence of ISE's implementation it should be said that their feature `call' has a precondition, and therefore correct code should actually look like that: my_operands := [my_meat] if p.valid_operands (my_operands) then p.call (my_operands) else -- try to call `p' with invalid operands end so in practice the cow should never eat meat at run-time. But this is relying on run-time checks, which is not fully satisfactory, especially for a statically typed language like Eiffel. In any case, even though SmartEiffel's implementation looks very promising and more flexible, it seems that both implementations have type holes. These type holes are very similar to CAT-calls (we can actually consider them as a derived version of CAT-calls). Note that in both examples above the CAT-call detector implemented in Gobo's gelint will report the potential problem. -- Eric Bezault mailto:ericb@gobosoft.com http://www.gobosoft.com |
|