[Ln 1, cl 1] +- Call: (to-num[10] three[6]) [Ln 1, cl 1] |+- Var: to-num[10] [Ln 1, cl 8] |:+- Var: three[6] [Ln 10, cl 14] |:|+- Case: case x[0] | succ y =>
This looks wrong to me: it claims that the evaluation of `case x ...` is performed as part of the lookup of the value of variable `three` which itself is made as part of the lookup of the value of the variable `to-num`.
But there is not such nesting: the lookup of `three` is performed after the lookup of `to-num` is finished and returned its value. And the `case x ...` is only performed after both lookups are finished and returned their value.
I think you're looking for something more like a *log*, which could look like:
[Ln 1, cl 1] +- Call: (to-num[10] three[6]) [Ln 1, cl 1] |+- Var: to-num[10] [Ln 1, cl 8] |+- Var: three[6] [Ln 10, cl 14] |+- Case: case x[0] | succ y => [Ln 9, cl 32] |:+- Call: (_+_[41] 1 (to-num[2] y[0])) [Ln 9, cl 32] |:|+- Var: _+_[41] [Ln 9, cl 18] |:|+- Imm: 1 [Ln 9, cl 23] |:|+- Call: (to-num[2] y[0]) [Ln 9, cl 23] |:|:+- Var: to-num[2] [Ln 9, cl 30] |:|:+- Var: y[0] [Ln 10, cl 14] |:|:+- Case: case x[0] | succ y => [Ln 9, cl 32] |:|:|+- Call: (_+_[41] 1 (to-num[2] y[0])) [Ln 9, cl 32] |:|:|:+- Var: _+_[41] [Ln 9, cl 18] |:|:|:+- Imm: 1 [Ln 9, cl 23] |:|:|:+- Call: (to-num[2] y[0]) [Ln 9, cl 23] |:|:|:|+- Var: to-num[2] [Ln 9, cl 30] |:|:|:|+- Var: y[0] [Ln 10, cl 14] |:|:|:|+- Case: case x[0] | succ y => [Ln 9, cl 32] |:|:|:|:+- Call: (_+_[41] 1 (to-num[2] y[0])) [Ln 9, cl 32] |:|:|:|:|+- Var: _+_[41] [Ln 9, cl 18] |:|:|:|:|+- Imm: 1 [Ln 9, cl 23] |:|:|:|:|+- Call: (to-num[2] y[0]) [Ln 9, cl 23] |:|:|:|:|:+- Var: to-num[2] [Ln 9, cl 30] |:|:|:|:|:+- Var: y[0] [Ln 10, cl 14] |:|:|:|:|:+- Case: case x[0] | succ y => [Ln 10, cl 13] |:|:|:|:|:|+- Imm: 0
and this example is misleading, because the log wouldn't only get deeper: it'd contain the whole trace of execution.
Stefan