Honestly, I'd prefer to have to annotate non-exhaustive records: let { foo = foo; bar = bar } = x should only match { foo; bar }, but let { foo = foo; bar = bar; .. } = x, can match records with more labels. PKE. Yaron Minsky wrote: > On Tue, Apr 14, 2009 at 10:12 AM, Yoann Padioleau > wrote: > > > So, would it be possible to extend the ocaml compiler with a simple > feature that let the programmer tell the compiler when he use > an "exhaustive" pattern with record, e.g. > > let foo = function > { field1 = v1; field2 = v2; NOTHING_ELSE} -> > > > I think this is a great idea (and something I've blogged about before, > as Christophe Troestler points out). The thing I've never come up > with a good proposal for is what would be a pleasant syntax to > indicate the exhaustiveness of the pattern match. I could imagine > something terse like this: > > let {! foo = foo; bar = bar; } = x > > where the ! indicates that the pattern match should be exhaustive. > Such terse notation would sadly be somewhat obscure. > > Another thought I've had for making record matches lighter is to do > the same kind of trick that's done with labeled arguments, i.e., have > > let { foo; bar } = x > > bind the variable foo to the x.foo, and bind bar to x.bar. > Similarly, it might be nice for: > > let foo = 3 and bar = 3. in { foo;bar } > > to be equivalent to > > let foo = 3 and bar = 3. in { foo = foo; bar = bar } > > y > -- Pål-Kristian Engstad (engstad@naughtydog.com), Lead Graphics & Engine Programmer, Naughty Dog, Inc., 1601 Cloverfield Blvd, 6000 North, Santa Monica, CA 90404, USA. Ph.: (310) 633-9112. "Emacs would be a far better OS if it was shipped with a halfway-decent text editor." -- Slashdot, Dec 13. 2005.