Browse thread
[Caml-list] Constructors as functions and tuples in constructors
[
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: | Dan Grossman <djg@c...> |
| Subject: | Re: [Caml-list] Constructors as functions and tuples in constructors |
Serge wrote: > First, it would be nice to have constructors as functions like below: > > List. map Some [17] Leads to strange error messages and is trivially circumventable (replace Some with fun x -> Some x) > Second, it would also be nice not to have "the concept of constructor > arity", and treat the code below as correct: > > type t = A of int * int > let _ = > match A (17, 0) with > A z -> match z with (x, y) -> () Works with type t = A of (int * int). You put the parens in. So the choice is yours. The advantage of leaving them out is usually performance. Others can give the long version of these answers... --Dan ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners