From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p9GIpnDL015715 for ; Sun, 16 Oct 2011 20:51:49 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArICAMUmm07VUZiOfWdsb2JhbABChHWkDwEBCwsJBxQGIYIYBAwJATsaHAIFFgsCCwMCAQIBSw0IAod9lgONbpBQgTCFRIEUBJN6hSmMLw X-IronPort-AV: E=Sophos;i="4.69,354,1315173600"; d="scan'208";a="113100839" Received: from mylady.t-com.sk (HELO smtp.t-com.sk) ([213.81.152.142]) by mail4-smtp-sop.national.inria.fr with ESMTP; 16 Oct 2011 20:51:44 +0200 MIME-version: 1.0 Content-transfer-encoding: 8BIT Content-type: text/plain; charset=UTF-8 Received: from [10.0.0.4] ([unknown] [95.103.32.20]) by relay1.stonline.sk (STOnline ESMTP Server) with ESMTPA id <0LT600D679Q62N00@relay1.stonline.sk> for caml-list@inria.fr; Sun, 16 Oct 2011 20:51:43 +0200 (CEST) Message-id: <4E9B27A1.5070309@fiit.stuba.sk> Date: Sun, 16 Oct 2011 20:51:13 +0200 From: Matej Kosik User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20111004 Icedove/3.0.11 To: Caml List X-Enigmail-Version: 1.0.1 OpenPGP: id=F248FE18; url=http://www2.fiit.stuba.sk/~kosik/doc/kosik.asc Subject: [Caml-list] Ocaml: typing by name vs. typing by structure Hello, When I try to compile the following program: let f1 = function {re=a;im=b} -> print_float a; print_float b in f1 {re=10.0;im=20.0 I get an error message: File "tmp.ml", line 2, characters 2-13: Error: Unbound record field label re I know how to "fix" the program to be compilable---I have to add type whatever = {re:float; im:float} at the top. Then type inference is able to figure out that "f1" has type "whatever -> unit". Why did language designers chosen: - typing by structure in case of tuples (tuples can be viewed as records with unlabled fields), - typing by name in case of records. Why wasn't typing by structure chosen both for tuples and for records? If it were, then type of "f1" would be "{re=float;im=float}". Best regards. -- Matej Košík