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 KAA18362; Sat, 17 May 2003 10:13:34 +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 KAA05340 for ; Sat, 17 May 2003 10:13:33 +0200 (MET DST) Received: from mail.exomi.com (mail.exomi.com [217.169.64.72]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h4H8DWT04603 for ; Sat, 17 May 2003 10:13:33 +0200 (MET DST) Received: from exomi.com (unknown [10.0.5.5]) by mail.exomi.com (Postfix) with ESMTP id C61355DE2; Sat, 17 May 2003 11:13:31 +0300 (EEST) Date: Sat, 17 May 2003 11:13:30 +0300 Subject: Re: [Caml-list] Sumtypes of records Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) Cc: To: Chris Hecker From: Ville-Pertti Keinonen In-Reply-To: <4.3.2.7.2.20030516182821.042f6dd0@localhost> Message-Id: <71A9CFA4-883F-11D7-BDA3-000393863F70@exomi.com> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.552) X-Spam: no; 0.00; caml-list:01 record-like:01 int:01 match:02 age:96 obj:03 arguments:03 types:03 probably:05 definition:06 feature:07 type:07 tuple:07 defines:08 comment:08 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > I disagree, it would be useful, it's far more self-documenting than a > tuple (which usually need a record-like comment right next to their > declaration to tell what's what), and you could match the record like > > Bar x -> x.age > > and it wouldn't need a type name. I've wanted this feature myself a > number of times. If you can say Bar x -> x.age, you can say Bar x -> x, which implies that the type of x should be a type in its own right, independent of Bar. I think this is consistent. > It has type { age : int; }, just like int * int has type int * int and > doesn't need a name. Does the record need a name for some other > reason? int * int denotes a type, { age : int } defines a type. One { age : int } is not compatible with a different { age : int }. It would probably be possible for { age : int } to be made a valid type expression, but it would change the language significantly and provide you with fairly little gain (it would save you one type definition when using it as part of a sum type). Also note that sum types of records are less storage-efficient than sum types with multiple arguments (the record is indirect, because you must be able to write Bar x -> x). Incidentally, if the record weren't indirect, Bar x could be Obj.magic-compatible with x, but that's just a detail of the implementation... ------------------- 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