Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OCaml Trace: what is the star?

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?

like image 416
Gus Avatar asked Feb 06 '13 14:02

Gus


1 Answers

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
like image 198
gasche Avatar answered Oct 02 '22 23:10

gasche