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
pattern matching and records vs tuples
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-04-17 (00:26)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] pattern matching and records vs tuples
From: "David Allsopp" <>

> The other worry in the back of my mind is that despite having
> considerably more flexible records in SML (you don't have to declare
> the types in advance and label sharing is possible), a function in
> SML still has the restriction of only being over a fixed record
> type... and when SML has odd restrictions, they're usually to do with
> the more "obvious" type system feature being undecideable. For
> example, you can't say in SML:
> fun get_x r = #x r;
> as the equivalent of the OCaml get_x you propose.

You can do this with SML#

 # fun f x = #name x;
 val f = fn : ['a, 'b#{name:'a}. 'b -> 'a]
 # f {name = "Joe", age = 21};
 val it = "Joe" : string

But the compiler is rather clever...

Jacques Garrigue