When functions are traced using #trace
in OCaml, the output may include something like this:
subRec --> <fun>
subRec* <-- "_1"
subRec* --> <fun>
subRec** <-- Var "_1"
What do the stars/splats mean?
This is used to mark the result of partial applications to a currified
function. let f x y = ...
is equivalent to let f x = fun y -> ...
:
applying the x
parameter returns a new function that, in turn, takes
an y
parameter to compute. The first function will be traced as f
,
and the second (returned by, say, f 1
) marked f*
.
# let f x y = x + y;;
# #trace f;;
# f 1 2;;
f <-- 1
f --> <fun>
f* <-- 2
f* --> 3
- : int = 3
# let g = f 1;;
f <-- 1
f --> <fun>
val g : int -> int = <fun>
# g 2;;
f* <-- 2
f* --> 3
- : int = 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With