Tracing Joy Execution


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


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 the function, then print it to see the trace.


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 viewer argument to the function.

  • quote (stack) – A stack.
  • expression (stack) – A stack.