From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 5292ABBAF for ; Fri, 30 May 2008 03:13:19 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkEBAPPxPkjAXQImiGdsb2JhbACSKgEBAQ8gnSM X-IronPort-AV: E=Sophos;i="4.27,563,1204498800"; d="scan'208";a="13236389" Received: from discorde.inria.fr ([192.93.2.38]) by mail3-smtp-sop.national.inria.fr with ESMTP; 30 May 2008 03:13:18 +0200 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m4U1DEqc007959 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Fri, 30 May 2008 03:13:18 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Al8AAHvxPkiD1+8TmWdsb2JhbACSKgEBAQEBCAUGCREFnRo X-IronPort-AV: E=Sophos;i="4.27,563,1204498800"; d="scan'208";a="12935304" Received: from outgoing-mail.its.caltech.edu ([131.215.239.19]) by mail1-smtp-roc.national.inria.fr with ESMTP; 30 May 2008 03:13:17 +0200 Received: from earth-dog.its.caltech.edu (earth-dog [192.168.1.3]) by water-ox-postvirus (Postfix) with ESMTP id 595D21B73B; Thu, 29 May 2008 18:13:15 -0700 (PDT) Received: from [198.18.191.245] (unknown [208.110.0.2]) (Authenticated sender: mvanier) by earth-ox.its.caltech.edu (Postfix) with ESMTP id C52731BB13; Thu, 29 May 2008 18:13:11 -0700 (PDT) Message-ID: <483F54A5.4020808@cs.caltech.edu> Date: Thu, 29 May 2008 18:13:09 -0700 From: Michael Vanier User-Agent: Thunderbird 2.0.0.14 (X11/20080421) MIME-Version: 1.0 To: Adam Granicz Cc: "caml-list@inria.fr" Subject: Re: [Caml-list] syntax question References: <483F2CEC.7020701@cs.caltech.edu> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 483F54AA.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; vanier:01 mvanier:01 syntax:01 afaik:01 ocaml:01 foo:01 foo:01 0200,:01 vanier:01 mvanier:01 syntax:01 val:01 compiler:01 beginner's:01 ocaml:01 Adam, I realize that this is how it works, but I don't understand why it should work this way. AFAIK elsewhere in ocaml "int * int" always refers to a tuple. Similarly, if testme's Foo really took two int arguments I would expect to be able to create Foos as "Foo 1 2" instead of "Foo (1, 2)" which looks like Foo takes a single tuple argument, not two int arguments. I don't see why "int * int" and "(int * int)" are different things. Mike Adam Granicz wrote: > Hi Michael, > > In the type definition > >> # type testme = Foo of int * int;; > > the constructor Foo takes *two* int arguments (thus, you can not > construct a testme value supplying only one argument), whereas in > >> # type testme2 = Foo2 of (int * int);; > > it takes *one* tuple argument. > > Regards, > Adam. > > On Fri, 30 May 2008 00:23:40 +0200, Michael Vanier > wrote: > >> Hi everyone, >> >> I got bitten by a simple syntax problem: >> >> # let a = (1, 2);; >> val a : int * int = (1, 2) >> # type testme = Foo of int * int;; >> type testme = Foo of int * int >> # Foo a;; >> The constructor Foo expects 2 argument(s), >> but is here applied to 1 argument(s) >> # Foo (1, 2);; >> - : testme = Foo (1, 2) >> # type testme2 = Foo2 of (int * int);; >> type testme2 = Foo2 of (int * int) >> # Foo2 a;; >> - : testme2 = Foo2 (1, 2) >> >> Why does the compiler treat int * int and (int * int) in type >> definitions so differently? Is it to give clearer error messages in >> the typical case? >> >> Mike >> >> >> >> >> _______________________________________________ >> Caml-list mailing list. Subscription management: >> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list >> Archives: http://caml.inria.fr >> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >> Bug reports: http://caml.inria.fr/bin/caml-bugs > > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs