Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Constructors as functions and tuples in constructors
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-10-08 (16:07)
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...


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: