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 JAA00215 for caml-red; Thu, 7 Dec 2000 09:13:44 +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 WAA03574 for ; Wed, 6 Dec 2000 22:22:30 +0100 (MET) Received: from tor.abc.se (ns.abc.se [195.17.72.11]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id eB6LMTj09917 for ; Wed, 6 Dec 2000 22:22:29 +0100 (MET) Received: from gateway (dialup-71 [195.17.73.71]) by tor.abc.se (8.9.3+Sun/8.9.3) with SMTP id WAA22606 for ; Wed, 6 Dec 2000 22:22:28 +0100 (MET) From: "Mattias Waldau" To: "Caml-List" Subject: Same label in different types, how do people solve this? Date: Wed, 6 Dec 2000 22:22:24 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Sender: weis@pauillac.inria.fr In Ocaml, you cannot have the same label in different types, see the example below where point_2d hides point_3d. How do people normally code around this restriction? One solution is using objects, but what other solutions are there? Can 'Polymorphic variants' solve this? Also, I am a bit curious why it doesn't help to type explicitely, i.e. to write let x:point_3d={x=10.;y=20.;z=30.} ??? /mattias type point_3d = { x:float; y:float; z:float; } type point_2d = { x:float; y:float; } # {x=10.;y=20.;z=30.};; Characters 0-19: The record field label z belongs to the type point_3d but is here mixed with labels of type point_2d # {x=10.;y=20.};; - : point_2d = {x=10.000000; y=20.000000}