Display, a Recursive Value Printer
Next we’ll take a look at how to improve the display of composite
types. Rather than try to copy
we’ll build a debugging utility function called
given an arbitrarily complex value
x, prints the complete
structure of that value, labeling each element
with the path by which it was found.
Let’s start with an example.
e, _ := eval.Parse("sqrt(A / pi)") Display("e", e)
In the call above, the argument to
Display is a syntax
tree from the expression evaluator in Section 7.9.
The output of
Display is shown below:
Display e (eval.call): e.fn = "sqrt" e.args.type = eval.binary e.args.value.op = 47 e.args.value.x.type ...