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=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id B17EBBBAF for ; Fri, 30 May 2008 03:54:33 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlsAANv6PkgRlBBSmWdsb2JhbACSKgEBAQEBCAUGCREDnRU X-IronPort-AV: E=Sophos;i="4.27,564,1204498800"; d="scan'208";a="11310757" Received: from smtpoutm.mac.com ([17.148.16.82]) by mail2-smtp-roc.national.inria.fr with ESMTP; 30 May 2008 03:54:32 +0200 Received: from smtpin124.mac.com (smtpin124-bge351000 [10.150.68.124]) by smtpoutm.mac.com (Xserve/smtpout019/MantshX 4.0) with ESMTP id m4U1sVDA002231 for ; Thu, 29 May 2008 18:54:31 -0700 (PDT) MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes Received: from [192.168.8.152] (c-24-218-151-219.hsd1.ma.comcast.net [24.218.151.219]) by smtpin124.mac.com (Sun Java(tm) System Messaging Server 6.3-6.03 (built Mar 14 2008; 32bit)) with ESMTPSA id <0K1N001JLRYJB580@smtpin124.mac.com> for caml-list@yquem.inria.fr; Thu, 29 May 2008 18:54:31 -0700 (PDT) Message-id: <48167D57-C029-4568-B01D-49C00DFE4680@mac.com> From: Gordon Henriksen To: caml-list@yquem.inria.fr In-reply-to: <483F54A5.4020808@cs.caltech.edu> Content-transfer-encoding: quoted-printable Subject: Re: [Caml-list] syntax question Date: Thu, 29 May 2008 21:54:29 -0400 References: <483F2CEC.7020701@cs.caltech.edu> <483F54A5.4020808@cs.caltech.edu> X-Mailer: Apple Mail (2.924) X-Spam: no; 0.00; syntax:01 constructors:01 allocations:01 vanier:01 afaik:01 ocaml:01 foo:01 foo:01 0200,:01 vanier:01 mvanier:01 syntax:01 val:01 compiler:01 beginner's:01 Michael, A of a * a is more memory efficient than A of (a * a). In effect, a =20 variant IS a tuple. If you wish to restrict yourself to restrict =20 yourself to unary constructors in your programs, you're free to do so =20= at the cost of extra allocations. On 2008-05-29, at 21:13, Michael Vanier wrote: > Adam, > > I realize that this is how it works, but I don't understand why it =20 > should work this way. AFAIK elsewhere in ocaml "int * int" always =20 > refers to a tuple. Similarly, if testme's Foo really took two int =20 > arguments I would expect to be able to create Foos as "Foo 1 2" =20 > instead of "Foo (1, 2)" which looks like Foo takes a single tuple =20 > argument, not two int arguments. I don't see why "int * int" and =20 > "(int * int)" are different things. > > Mike > > Adam Granicz wrote: >> Hi Michael, >> In the type definition >>> # type testme =3D Foo of int * int;; >> the constructor Foo takes *two* int arguments (thus, you can not =20 >> construct a testme value supplying only one argument), whereas in >>> # type testme2 =3D 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 =3D (1, 2);; >>> val a : int * int =3D (1, 2) >>> # type testme =3D Foo of int * int;; >>> type testme =3D 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 =3D Foo (1, 2) >>> # type testme2 =3D Foo2 of (int * int);; >>> type testme2 =3D Foo2 of (int * int) >>> # Foo2 a;; >>> - : testme2 =3D Foo2 (1, 2) >>> >>> Why does the compiler treat int * int and (int * int) in type =20 >>> definitions so differently? Is it to give clearer error messages =20= >>> 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 > > _______________________________________________ > 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 =97 Gordon