Date: Mon, 25 May 1998 13:46:19 +0200
From: Hendrik Tews <firstname.lastname@example.org>
Subject: co(ntra)-variant subtyping
Objective Caml's subtyping algorithm does not subtype under type
constructors (but it does it under abbreviations), for the sake of
efficiency. That is, eventhough colored_point :> point, you don't have
colored_point option :> point option. This equation would be needed to
check the subtyping in method move of example 2.
I must say I am really surprised.
How about object types? Do they support co(ntra)-variant
I would suggest to include a section about the subtype relation
in the ocaml documentation. Because IMHO anybody how knows
something about formal models for oo languages would expect
co(ntra)-variant subtype rules.
In summary I think the lack of these subtype rules are a major
restriction of the ocaml language. Now it is not possible to mix
class types and (algebraic) data types in an application. Instead
a user has to decide beforehand what is more important for him:
algebraic data types and parametric polymorphism or object types
with code reuse and stepwise refinement.
Are there any plans to add the missing subtype rules to the type
system of ocaml?
This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:14 MET