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 SAA14359 for caml-red; Mon, 11 Dec 2000 18:47:21 +0100 (MET) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA00581; Mon, 11 Dec 2000 18:19:47 +0100 (MET) From: Pierre Weis Message-Id: <200012111719.SAA00581@pauillac.inria.fr> Subject: Re: Same label in different types, how do people solve this? In-Reply-To: from Brian Rogoff at "Dec 8, 100 08:36:08 am" To: bpr@best.com (Brian Rogoff) Date: Mon, 11 Dec 2000 18:19:47 +0100 (MET) Cc: caml-list@pauillac.inria.fr X-Mailer: ELM [version 2.4ME+ PL28 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: weis@pauillac.inria.fr > Mattias Waldau wrote : > > In Ocaml, you cannot have the same label in different types, see the > example > > below where point_2d hides point_3d. > > Troublemaker :-). There is a thread on this topic on comp.lang.functional. > Please, FAQ maintainer, this is very definitely FAQ material! Feel free to propose an entry for the FAQ (in english and french please): I would be glad to add it. [...] > Pierre Weis wrote > > I would suggest another syntactic notation to specify the type to > > which a label belongs: label@@type. > > > > {x@@p2d = 0; y = 5} > > r.x@@p2d > > I don't want to start a syntax war, but I think Ocaml is already suffering > a bit from too much added syntax and this doesn't look good to me. Jacques' > reuse of ":" (I know, it applies to the whole record and not a label) is > easier on my eyes, which already associate ":" with typing. > > -- Brian The notation I suggested is simpler to implement and specify: there is nothing new in type constraints propagation and label overloaing resolution strategy: just a notation to specify the type to which a label or constructor belongs to in the same spirit as usual qualification of names in the module system. Pierre Weis INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://cristal.inria.fr/~weis/