以下签名中的“#”是什么意思?
val insertBefore : #node Js.t -> #node Js.t -> #node Js.t Js.opt -> unit
以下签名中的“#”是什么意思?
val insertBefore : #node Js.t -> #node Js.t -> #node Js.t Js.opt -> unit
请参阅#-types
OCaml 参考手册部分 ( 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
函数g
可以采用类c
或其子类的对象。#c
是< x : int; ..>
因此的缩写,
let h = (g : < x : int; ..> -> int)
经过类型检查。