From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 6540C7F30A for ; Tue, 12 Mar 2013 12:30:18 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of lpw25@cam.ac.uk) identity=pra; client-ip=131.111.8.142; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="lpw25@cam.ac.uk"; x-sender="lpw25@cam.ac.uk"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of lpw25@cam.ac.uk) identity=mailfrom; client-ip=131.111.8.142; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="lpw25@cam.ac.uk"; x-sender="lpw25@cam.ac.uk"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@ppsw-42.csi.cam.ac.uk) identity=helo; client-ip=131.111.8.142; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="lpw25@cam.ac.uk"; x-sender="postmaster@ppsw-42.csi.cam.ac.uk"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqcCADURP1GDbwiOgWdsb2JhbABDxGGBShYOAQEWJiiCKAEBBAE6PwULCyElDwEESYggBq9+hxaJD48NB4NAA6pU X-IPAS-Result: AqcCADURP1GDbwiOgWdsb2JhbABDxGGBShYOAQEWJiiCKAEBBAE6PwULCyElDwEESYggBq9+hxaJD48NB4NAA6pU X-IronPort-AV: E=Sophos;i="4.84,830,1355094000"; d="scan'208";a="5782024" Received: from ppsw-42.csi.cam.ac.uk ([131.111.8.142]) by mail3-smtp-sop.national.inria.fr with ESMTP; 12 Mar 2013 12:30:17 +0100 X-Cam-AntiVirus: no malware found X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from kingston.cl.cam.ac.uk ([128.232.64.15]:43372) by ppsw-42.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.159]:587) with esmtpsa (PLAIN:lpw25) (TLSv1.2:DHE-RSA-AES128-GCM-SHA256:128) id 1UFNPN-00039p-7c (Exim 4.80_167-5a66dd3) (return-path ); Tue, 12 Mar 2013 11:30:17 +0000 From: Leo White To: Goswin von Brederlow Cc: caml-list@inria.fr References: <20130311103139.GA3683@frosties> Date: Tue, 12 Mar 2013 11:30:16 +0000 In-Reply-To: <20130311103139.GA3683@frosties> (Goswin von Brederlow's message of "Mon, 11 Mar 2013 11:31:39 +0100") Message-ID: <87a9q897p3.fsf@kingston.cl.cam.ac.uk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Caml-list] Record field disambiguation in 4.01 > I think this show a problem of how types propagate only in one direction. > > p1 and p2 are both the same type but p1 gets infered corectly while p2 > needs the type annotation to avoid a warning. Lets look at the types: > > [...] > > It would be nice if the type inference and disambiguation would allow > type information to flow both ways. Not just from first use to last > but also from last use to first. Up, down, left and right in the tree > representation of the code. > > Maybe the use of p2.y with .* (or in general disambiguation on the > expected type of the label) because it could lead to hard to follow > resolution of ambiguous record use. But the p2.x is a clear indication > of what type the programmer wanted. While in a way it is the opposite of what you're asking for, you can get more consistent behaviour by using the "-principal" argument: # let cross_product p1 p2 = p1.x *. p2.y -. p1.y *. p2.x ;; Characters 41-42: p1.x *. p2.y -. p1.y *. p2.x ^ Warning 41: this use of y is ambiguous. Characters 49-50: p1.x *. p2.y -. p1.y *. p2.x ^ Warning 41: this use of y is ambiguous. Regards, Leo