Browse thread
syntax question
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Michael Vanier <mvanier@c...> |
| Subject: | Re: [Caml-list] syntax question |
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 > <mvanier@cs.caltech.edu> 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