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 OAA07269 for caml-redistribution; Mon, 22 Feb 1999 14:10:47 +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 JAA21054 for ; Mon, 22 Feb 1999 09:44:32 +0100 (MET) Received: from post.tepkom.ru (relay.tepkom.ru [195.9.240.162]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id JAA02412; Mon, 22 Feb 1999 09:44:25 +0100 (MET) Received: from localhost (msk@localhost) by post.tepkom.ru (8.8.7/8.8.7) with ESMTP id LAA16383; Mon, 22 Feb 1999 11:44:32 +0300 Date: Mon, 22 Feb 1999 11:44:32 +0300 (MSK) From: Anton Moscal To: Xavier Leroy cc: 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: > It could be implemented this way. However, if you declare the > datatype as > > type foo = A of {lbl1 : int; lbl2 : int} > > you would be forced to pattern-match it as follows > > match x with A{lbl1 = x; lbl2 = y} -> ... > > but you can't get access to the record itself and use the dot notation > on it, as in > > match x with A r -> ... r.x ... r.y ... But why? Natural semantic for anonymous types is the following: each anonymous record or algebraic types declaration introduces new type declaration in the current scope with some temporary type name. I.e. type ('a, 'b) foo = A of 'a * {l : 'b; l2: int} is a shortcut for: type ('a, 'b) temp_name = {l1 : 'b; l2: int} and ('a, 'b) foo = A of 'a * ('a, 'b) temp_name Regards, Anton Moscal