In the fall of 1995, Meyer [Mey95] proposed a different solution to the covariance typing problems. His solution was to identify and ban what he called polymorphic catcalls . While this notion is too complex to be defined here, this proposal was intended to bar particular kinds of message sends to objects whose type was not known exactly.
To illustrate how this proposal would preserve type safety, let us return to our example procedure in Figure 13 which shows that subclasses need not be subtypes. In that example the message was sent to , where was a parameter declared to have type . The problem arose when the actual parameter corresponding to actually had type . We avoided this problem by not allowing to be a subtype of since was a binary method.
Meyer's new proposal would avoid the problem as follows. He would label a catcall since the type of the formal parameter of is changed in a covariant way in a subclass of . The receiver would be termed polymorphic since the exact type of its value is unknown. This follows since it is a formal parameter and hence any element of a subclass of may be used as a parameter. Hence the entire expression is considered a polymorphic catcall and hence is illegal.
An interesting part of the definition is that the original expression would not be considered a catcall until a subclass of is declared. Thus the procedure would be legal in an Eiffel program unless and until a subclass is defined. Meyer argues that an incremental compiler could determine this change in status at no great cost.
Thus in the solution proposed earlier in this paper, the procedure is legal, but it may only be applied to parameters of type (since has no subtypes). We could also use match-bounded polymorphism to rewrite the procedure as in Figure 21. This is still type safe, but is more flexible in that it would allow calls of the form as long as and both have type . In particular it could be called with and two actual parameters of type .
In Meyer's proposal, the original would be legal only as long as had no subclasses. When the first subclass was defined, the procedure would become illegal and have to be rewritten or eliminated.
We have several concerns with Meyer's new proposal.
Only experience with these rules will determine whether or not there is any validity to these concerns. Meanwhile, the type system discussed in this paper provides an alternative solution to the covariant typing problems of Eiffel, albeit one that requires the programmer to plan ahead.