js_of_ocaml dom类型前面#字符的含义

Ant*_*ine 1 ocaml js-of-ocaml

以下签名中"#"的含义是什么?

val insertBefore : #node Js.t -> #node Js.t -> #node Js.t Js.opt -> unit
Run Code Online (Sandbox Code Playgroud)

cam*_*ter 5

请参阅#-typesOCaml参考手册(http://caml.inria.fr/pub/docs/manual-ocaml/types.html)部分.

函数类型#node -> t接受类node或其子类的对象并返回t.

例如,

class c = object method x = 1 end

let g : #c -> int = fun o -> o#x
Run Code Online (Sandbox Code Playgroud)

函数g可以接受类c或其子类的对象.#c< x : int; ..>因此的缩写,

let h = (g : < x : int; ..> -> int)
Run Code Online (Sandbox Code Playgroud)

是经过类型检查的.