I wonder if the boom of dynamic languages is not the effect of the incorrectly stated limits of statically typed languages like Java or C#.
It is pretty basic, but anyway:
interface Contract def compute(input String) Object; end
Interface is a contract indeed — in this example we say that if you refine compute
you should be able to tackle with String
in input and Object
in output. But let’s say we write:
class Worker refines Contract refines def compute(input Object) Int ••• end
Did we just violate the contract of the interface? No — we were supposed to produce Object
, and Int
is Object
. We were supposed to cope with String
in the input and we do even better — we handle all possible types (nothing is higher in type hierarchy than Object
). We fulfilled the contract and added a bonus for those who use Worker
type directly.
Well, I cannot speak for other languages, but Skila supports both sides of the refinement.