Tracing Joy Execution¶
joy.utils.pretty_print¶
Pretty printing support, e.g.:
Joy? 23 18 * 99 +
. 23 18 mul 99 add
23 . 18 mul 99 add
23 18 . mul 99 add
414 . 99 add
414 99 . add
513 .
513 <-top
joy?
On each line the stack is printed with the top to the right, then a . to
represent the current locus of processing, then the pending expression to the
left.
-
class
joy.utils.pretty_print.TracePrinter[source]¶ This is what does the formatting. You instantiate it and pass the
viewer()method to thejoy.joy.joy()function, then print it to see the trace.-
go()[source]¶ Return a list of strings, one for each entry in the history, prefixed with enough spaces to align all the interpreter dots.
This method is called internally by the
__str__()method.Return type: list(str)
-
viewer(stack, expression)[source]¶ Record the current stack and expression in the TracePrinter’s history. Pass this method as the
viewerargument to thejoy.joy.joy()function.Parameters: - quote (stack) – A stack.
- expression (stack) – A stack.
-