`运营商在OCaml中做了什么?
let int_of_meth = function
| `GET -> 0
| `POST -> 1
| `PUT -> 2
| `DELETE -> 3
| `HEAD -> 4
| `PATCH -> 5
| `OPTIONS -> 6
| _ -> failwith "non standard http verbs not supported"
Run Code Online (Sandbox Code Playgroud)
我在OCaml手册中找不到它.
这`不是一个真正的运营商.它适用于词法层面(如字符串的引号),并将以下符号变为"多态变体".请参阅@Edgar Aroutiounian给出的链接:
http://caml.inria.fr/pub/docs/manual-ocaml-4.00/manual006.html#toc36
更新
实际上,`如@gsg所述,它被扫描为单独的符号.所以多态变体就像` Abc是一个句法结构.我仍然声称它不是通常意义上的操作员.
(编辑:改为Abc.我从来不知道它们应该被大写.例如,lablgl接口似乎始终使用小写.)