【发布时间】:2016-03-31 09:17:06
【问题描述】:
OCaml 有一个明确的句法结构(参见Parsetree.pattern_desc, constructor Ppat_record)来区分“打开”和“关闭”记录模式。
这似乎对模式匹配没有任何影响:
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>
那么它的目的是什么?这是某种 SML 遗物吗?
【问题讨论】:
标签: pattern-matching ocaml record