Browse thread
pattern matching and records vs tuples
[
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: | 2009-04-17 (00:26) |
From: | Jacques Garrigue <garrigue@m...> |
Subject: | Re: [Caml-list] pattern matching and records vs tuples |
From: "David Allsopp" <dra-news@metastack.com> > 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# http://www.pllab.riec.tohoku.ac.jp/smlsharp/ # 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