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
Execution time of class versus record
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-06-26 (00:15)
From: Chris King <colanderman@g...>
Subject: Re: [Caml-list] Execution time of class versus record
On 6/25/07, Jonathan Bryant <> wrote:
> I've always been a little curious about this.  Is performance the
> _only_ reason for this distinction?  Construction and pattern
> matching on the two are identical, and AFAIK neither doesn't allow
> partial application.

Using the tupled form, you can pattern-match the tuple as a whole.  E.g.

# type t = A of (int * int);;
# match A (1,2) with A x -> x;;
int * int = (1, 2)

This isn't allowed with the non-tupled form.  Same goes for
construction.  (This is where the non-tupled form can actually cost
you, if you need to pass around its arguments as a tuple somewhere.)

- Chris