From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id EAA05485; Sat, 5 Jul 2003 04:21:17 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id EAA07926 for ; Sat, 5 Jul 2003 04:21:16 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h652LET00355 for ; Sat, 5 Jul 2003 04:21:14 +0200 (MET DST) Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3p2/3.7W) with ESMTP id LAA02004; Sat, 5 Jul 2003 11:21:09 +0900 (JST) To: vrotaru@seznam.cz Cc: caml-list@inria.fr Subject: Re: [Caml-list] subtyping, polymorphism, higher order types..... In-Reply-To: <20030704224521.7db3450f.vrotaru@seznam.cz> References: <3F043EAB.70503@mitre.org> <20030704224521.7db3450f.vrotaru@seznam.cz> X-Mailer: Mew version 1.94.2 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20030705112126Q.garrigue@kurims.kyoto-u.ac.jp> Date: Sat, 05 Jul 2003 11:21:26 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; jacques:01 caml-list:01 subtyping:01 seznam:99 subsumption:01 incompatible:01 inference:01 influences:01 oberon:01 extensible:01 recognized:99 supertype:01 encode:01 ocaml:01 coerce:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Vasile Rotaru > On Thu, 03 Jul 2003 10:33:15 -0400 > Shaddin Doghmi wrote: > > > In my experiences with ocaml, one of the major frustrations i > > constantly run into is the lack of subtyping. [..] You should be a bit more precise: ocaml has both explicit subtyping (for objects), and parametric polymorphism (which is also a form of implicit subsumption). So what it does not have is only the form of implicit subtyping you are used to, and which is incompatible with most forms of type inference. > The Shaddin message (and other influences -- the most notable being > the Oberon language) had induced me to an idea which I offer here for > discussion. Open (or extensible) product types. Something like this > > type point = int * int * _ ;; > > where the underscore stands for any sequences of types. Colour, taste, > strangeness, etc. > > Now a function designed to work with with "point" will work with any > type which is a "point" extension. Just now I cannot think of a good > "ocamlish" syntax for extending types. Maybe? > > type color_point = * int * _ > > The big question is what this will do with the type system of Ocaml > and whether it worth the pain.. This looks very much like an ocaml object type to me... Is the absence of labels for fields important? Note that you can also encode the above with polymorphism: type 'a point = int * int * 'a type 'a color_point = (int * 'a) point The only trouble here is that there is no way to create heterogeneous collections, since you cannot coerce a [unit color_point] to a [unit point]. Actually, this just comes from a missing relation in the ocaml type algebra: the type Obj.t is not recognized as a supertype for all types. If this were the case then you would be able to write: let l = [ (p :> Obj.t point); (cp :> Obj.t point) ] That would be easy enough to add, but is it that useful? Jacques Garrigue ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners