# Tracing Joy Execution

## `joy.utils.pretty_print`

Pretty printing support, e.g.:

    Joy? [23 18 * 99 +] trace
           • 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 left, then a bullet symbol,``•``, to represent the current locus of processing, then the pending expression to the right.

class `joy.utils.pretty_print.``TracePrinter`

  This is what does the formatting. You instantiate it and pass the `viewer()` method to the `joy.joy.joy()` function, then print it to see the trace.

  `go`()

    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)

    Record the current stack and expression in the TracePrinter’s history. Pass this method as the `viewer` argument to the `joy.joy.joy()` function.

    Parameters: | quote (stack) – A stack. expression (stack) – A stack.

`joy.utils.pretty_print.``trace`(stack, expression, dictionary)

  Evaluate a Joy expression on a stack and print a trace.

  This function is just like the i combinator but it also prints a trace of the evaluation

  Parameters: | stack (stack) – The stack. expression (stack) – The expression to evaluate. dictionary (dict) – A `dict` mapping names to Joy functions.
  Return type: | (stack, (), dictionary)