Reputation: 3567
OCaml has an explicit syntactic construct (See Parsetree.pattern_desc
, constructor Ppat_record
) to discriminate between "open" and "closed" record patterns.
This seems to have no influence whatsoever on the pattern matching:
utop # type r = {repr:int; foo:int} ;;
type r = { repr : int; foo : int; }
utop # let f = function {repr} -> repr;;
val f : r -> int = <fun>
utop # let g = function {repr;_} -> repr;;
val g : r -> int = <fun>
So what is/was its purpose? Is this some kind of SML relic?
Upvotes: 1
Views: 146
Reputation: 6379
It is just a language extension to tell the compiler that you ignored some fields on purpose so that you can have a warning when you forget a field.
http://caml.inria.fr/pub/docs/manual-ocaml/extn.html#sec226
Upvotes: 2