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 SAA31965 for caml-red; Mon, 11 Dec 2000 18:38:25 +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 PAA05061 for ; Sun, 10 Dec 2000 15:57:27 +0100 (MET) Received: from cs.huji.ac.il (cs.huji.ac.il [132.65.16.10]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id eBAEvQT22504 for ; Sun, 10 Dec 2000 15:57:26 +0100 (MET) Received: from zigzag.cs.huji.ac.il ([132.65.208.204]) by cs.huji.ac.il with esmtp (Exim 3.20 #1) id 1457un-0001NW-00 for caml-list@inria.fr; Sun, 10 Dec 2000 16:57:25 +0200 Received: (from orodeh@localhost) by zigzag.cs.huji.ac.il (8.9.3/1.1c) id QAA27523; Sun, 10 Dec 2000 16:57:25 +0200 Date: Sun, 10 Dec 2000 16:57:25 +0200 (IST) From: Ohad Rodeh To: caml-list@inria.fr Subject: Re: Same label in different types, how do people solve this? Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: weis@pauillac.inria.fr List, > ... stuff removed ... > > > 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.} ??? > > > > Because this is not the way it works. Labels are defined as are values > or constructors, this is only afterwards that the compiler checks that > they all belong to the same type. That is, the type cannot influence the > choice between x(point_3d) and x(point_2d), only the order of > definition can. > > There has been already various proposals for allowing types to be taken > into account when typing record labels. The difficulty is that as soon > as you make it into something useful, you loose the principal type > property, and that some theoreticians working on ocaml wouldn't like > it. The loss of the pricipal type theorem has also recently been discussed in comp.lang.ml and comp.lang.functional. Using type-annotation by the compiler prior (call this the PRIOR approach) to unification can help typing expression that cannot be typed otherwise. For example, cases of polymoriphic recursion. In fact, this is the way this is handled in Haskell (this topic has also appeared in this list previously). Although I wouldn't go running to implement all my code in Haskell :-), I do think that using PRIOR could be an improvement. Can someone provide an example of how principal typing is lost once anotations are used in a non-trivial way? Ohad.