是否有 OCaml '@@' 运算符,它是什么意思?
Is there an OCaml '@@' operator, and what does it mean?
我是 OCaml n00b,正在尝试理解以下源文件:
https://github.com/BinaryAnalysisPlatform/bap/blob/master/lib/bap_disasm/bap_disasm_shingled.ml
第46行有如下代码:
let static_successors gmin gmax lmem insn =
let fall_through =
if not (is_exec_ok gmin gmax lmem) then [None, `Fall]
else
let i = Word.((Memory.min_addr lmem) ++ (Memory.length lmem)) in
[Some i, `Fall] in
if (Insn.may_affect_control_flow insn) then (
let targets = (Insn.bil insn |> dests_of_bil) in
if (not @@ Insn.is_unconditional_jump insn) then
List.append fall_through targets
else
targets
) else fall_through
我明白了这个函数的大部分要点,但是 if (not @@ Insn.is_unconditional_jump insn
部分让我很困惑。我似乎找不到 @@
operator/function 的参考资料;它似乎以某种方式将函数应用于实例 insn
。
那么,@@
是一个内置运算符吗?如果是,它有什么作用?如果没有,我如何找到 operator/function 的声明,以便我可以找到它并找出答案?
此运算符是在 4.01 的 Pervasives
("always opened" 模块)中引入的。
基本上是('a -> 'b) -> 'a -> 'b
类型。所以 f @@ x
等价于 f x
.
好处是它的结合性和优先级。
在此特定情况下,not @@ Insn.is_unconditional_jump insn
与 not (Insn.is_unconditional_jump insn)
完全相同。
它被声明为一个内部原语,所以这对你没有多大帮助,但你可以在 OCaml manual.
中看到关于它的信息
我是 OCaml n00b,正在尝试理解以下源文件:
https://github.com/BinaryAnalysisPlatform/bap/blob/master/lib/bap_disasm/bap_disasm_shingled.ml
第46行有如下代码:
let static_successors gmin gmax lmem insn =
let fall_through =
if not (is_exec_ok gmin gmax lmem) then [None, `Fall]
else
let i = Word.((Memory.min_addr lmem) ++ (Memory.length lmem)) in
[Some i, `Fall] in
if (Insn.may_affect_control_flow insn) then (
let targets = (Insn.bil insn |> dests_of_bil) in
if (not @@ Insn.is_unconditional_jump insn) then
List.append fall_through targets
else
targets
) else fall_through
我明白了这个函数的大部分要点,但是 if (not @@ Insn.is_unconditional_jump insn
部分让我很困惑。我似乎找不到 @@
operator/function 的参考资料;它似乎以某种方式将函数应用于实例 insn
。
那么,@@
是一个内置运算符吗?如果是,它有什么作用?如果没有,我如何找到 operator/function 的声明,以便我可以找到它并找出答案?
此运算符是在 4.01 的 Pervasives
("always opened" 模块)中引入的。
基本上是('a -> 'b) -> 'a -> 'b
类型。所以 f @@ x
等价于 f x
.
好处是它的结合性和优先级。
在此特定情况下,not @@ Insn.is_unconditional_jump insn
与 not (Insn.is_unconditional_jump insn)
完全相同。
它被声明为一个内部原语,所以这对你没有多大帮助,但你可以在 OCaml manual.
中看到关于它的信息