Re: [Caml-list] syntax question

2008-05-30 Thread Damien Doligez
On 2008-05-30, at 03:13, Michael Vanier wrote: 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. Almost, but not quite: # let int = 2;; val int : int = 2 # int * int;; - : int = 4

Re: [Caml-list] syntax question

2008-05-30 Thread Luc Maranget
> 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 "F

Re: [Caml-list] syntax question

2008-05-30 Thread Christophe TROESTLER
On Thu, 29 May 2008 18:13:09 -0700, Michael Vanier wrote: > > 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

Re: [Caml-list] syntax question

2008-05-29 Thread Gordon Henriksen
Michael, A of a * a is more memory efficient than A of (a * a). In effect, a variant IS a tuple. If you wish to restrict yourself to restrict yourself to unary constructors in your programs, you're free to do so at the cost of extra allocations. On 2008-05-29, at 21:13, Michael Vanier wro

Re: [Caml-list] syntax question

2008-05-29 Thread Adam Granicz
Hi Mike, I suspect this was a choice made by the compiler writers - by special-casing constructors (thus making them different from ordinary functions) you avoid some "complications" (and create new ones), for instance no partial constructors (although IMHO there is a valid case for them

Re: [Caml-list] syntax question

2008-05-29 Thread Michael Vanier
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)" w

Re: [Caml-list] syntax question

2008-05-29 Thread Adam Granicz
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.

[Caml-list] syntax question

2008-05-29 Thread Michael Vanier
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) #