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 NAA26160 for caml-redistribution; Thu, 18 Feb 1999 13:21:49 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA06299 for ; Wed, 17 Feb 1999 20:11:27 +0100 (MET) Received: from morgon.inria.fr (morgon.inria.fr [128.93.8.33]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id UAA27273; Wed, 17 Feb 1999 20:11:24 +0100 (MET) Received: (from remy@localhost) by morgon.inria.fr (8.8.7/8.8.7) id UAA07513; Wed, 17 Feb 1999 20:14:04 +0100 Message-ID: <19990217201403.48891@morgon.inria.fr> Date: Wed, 17 Feb 1999 20:14:03 +0100 From: Didier Remy To: Christopher Jeris Cc: Xavier Leroy , caml-list@inria.fr Subject: Re: anonymous record types in variants Reply-To: Didier.Remy@inria.fr References: <19990217103259.47130@pauillac.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.85e In-Reply-To: ; from Christopher Jeris on Wed, Feb 17, 1999 at 01:09:06PM -0500 Organization: INRIA, BP 105, F-78153 Le Chesnay Cedex Phone: (33) 1 3963 5317 -- Sec: (33) 1 3963 5570 -- Fax: (33) 1 3963 5684 Web: http://cristal.inria.fr/~remy Sender: weis > But an analogous construction already exists in the object system: I was expecting this question... Yes, it is possible to have anonymous records and still keep principal types, using `polymorphic' records (a restriction of `extensible records') --this is the way objects are typed. However, this will cost at runtime, unless there are very severe, complicated compile-time/link-time optimizations. (In the case of objects, this cost is expected because you are programming by message invocation.) Since there are already objects in Ocaml, the need for polymorphic/extensible records is not so strong. This would be convenient but would not add much expressivity (you can always use objects). Hence the gain may be insufficient to justify a complication of the language and of the implementation. > 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; .. > Yes, but since this is a polymorphic type you have to write: type 'a foo = 'a constraint 'a = < one : int; ..>;; This captures the polymorphic row variable `..' (that you are not allowed to name directly) within the constrained type parameter 'a. Didier.