From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA09941 for caml-redistribution; Wed, 17 Feb 1999 19:43:52 +0100 (MET) 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 TAA19039 for ; Wed, 17 Feb 1999 19:09:24 +0100 (MET) Received: from math.mit.edu (MATH.MIT.EDU [18.87.0.8]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id TAA10605; Wed, 17 Feb 1999 19:09:22 +0100 (MET) Received: from severi (SEVERI.MIT.EDU [18.87.0.68]) by math.mit.edu (8.8.7/8.8.7) with ESMTP id NAA07811; Wed, 17 Feb 1999 13:09:05 -0500 (EST) Date: Wed, 17 Feb 1999 13:09:06 -0500 (EST) From: Christopher Jeris X-Sender: cjeris@severi.mit.edu To: Xavier Leroy , caml-list@inria.fr Subject: Re: anonymous record types in variants In-Reply-To: <19990217103259.47130@pauillac.inria.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: weis On Wed, 17 Feb 1999, Xavier Leroy wrote: > The reason why "{one : int}" is not a type expression but must be > declared and bound to a type name have to do with type inference > and the existence of principal types. If you allow record types in > type expressions (as in SML), some functions have no principal type, > such as fun x -> x.l. But an analogous construction already exists in the object system: # let f x = x#foo;; val f : < foo : 'a; .. > -> 'a = And indeed I can replace records by objects in my first example: type foo = One of < one : int > | Two of < two : string > But this doesn't solve the problem since (I think) I now have to name the object type in order to create objects which belong to it. So "open record types" { one : int; .. } are just not a good idea ? Another thing that kind of confuses me is open object types. Can the open object type < one : int; .. > be defined directly in any way ? type foo = < one : int; .. > is rejected since .. is unspecified. It seems that open object types can result from inferences about the types of other objects/functions, but not named directly ? (Or am I trying to do the wrong thing ?) Sorry if these questions are kind of elementary. I'm still chewing on the c/c0/c1/m example about 2/3 of the way through "Objects in Caml" :) thanks & peace, Chris Jeris MIT Math grad student & novice OCaml music programmer