Hyman Rosen said:
[...]
If the template happens to work for
some class that doesn't conform to T, why should it be prevented from doing
so?
Because in Eiffel its all about the contract.
When the interface accepts paramaters to conform to T the objects
author is taking on a responsibility to ensure that the feature will
always accept a paramater that conforms to T. The compiler will do
everything it can to help the author meet that commitment.
This means that when the author of another objects uses this object,
he can make sure that he meets the type requirements expressed in the
interface and then move on.
The contract works for both the programmers. The client programmer
can be confident that future updates to the library are not going to
break his code. The library programmer can be update code confident
that he will not cause any damage to his clients.
This extra effort helps to avoid situations like this one,
http://www.kuro5hin.org/story/2004/2/15/11942/2702, where Microsoft
developers are forced to code around the dependancy that Borland had
upon a bug.
In summary, you have at least 3 levels:
- Should always work.
- Happens to works now, but may change.
- Does not work.
The middle grey area can be a source of future problems, and should be
avoided. This is why somebody should be prevented from doing
something that happens to work.
Of course, how much benefit you attach to this all depends upon the
domain you work within. For some it is essential, for others it is
nuisance.