Browse thread
[Caml-list] record declaration, SML
[
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: | -- (:) |
| From: | brogoff@s... |
| Subject: | Re: [Caml-list] record declaration, SML |
On Fri, 10 Jan 2003, Xavier Leroy wrote:
> > There are a few other conveniences in SML record handling too, like the ...
> > notation, that don't exist in OCaml.
>
> You mean, in pattern-matching over records? Caml offers the same
> functionality without the ... notation, e.g.
>
> type r = { x: int; y: int }
>
> match r with { x = 1 } -> ...
>
> Because records are declared in advance, there is no requirement that
> all record labels be mentioned in a pattern matching.
Right, but if I'm not mistaken, SML forces you to use the ... in record
pattern matching when you want to ignore some labels in the match. As you
suggest, this is a lot more important in SML, but even in OCaml it would be
a bit better IMO to explicitly distinguish between ignoring some labels
and forgetting some, so that slovenly programmers (like yours truly) could
depend on the type checker to slap them when they miss fields. Unfortunately,
OCaml behaves as though every record pattern match had an implicit ..., so I
don't see a good way out even if the developers agreed that this was worth
fixing.
File that one under "petty complaints", or, if you're feeling generous in this
new year, under the non-petty "Oh how I wish we had more polymorphism in
records!" complaint :-)
-- Brian
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners