[英]OCaml: When guard in “fun”
If I'm reading it correctly, the OCaml documentation ( here , specifically) says that fun
can have "when" guards, such as: 如果我正确地阅读它,OCaml文档( 这里 ,特别是)说
fun
可以有“何时”警卫,例如:
fun a b when a < b -> a + b;;
However, this throws a syntax error on the "when". 但是,这会在“when”上引发语法错误。 What gives?
是什么赋予了? Am I reading this wrong?
我读错了吗?
More Info 更多信息
The relevant parts from the documentation are copied below in a BNF-like syntax: 下面以类似BNF的语法复制文档中的相关部分:
expr ::= ...
| fun multiple-matching
| ...
multiple-matching ::= { pattern }+ [when expr] -> expr
You found a bug of the documentation. 您发现了文档的错误。
fun
cannot take a guard. fun
不能带卫兵。
Note: the fix is already pull-requested: https://github.com/ocaml/ocaml-manual/pull/2 注意:该修复已经被请求了: https : //github.com/ocaml/ocaml-manual/pull/2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.