+++ title = "5c: Compiler Backend & Prettyprinter" weight = 45 template = "doc.html" +++ (To be fully documented) ## `++slog` Deify printf Prints stack trace `a` if the stack trace isn't null, then produces the other input. `+slog` first takes `a`, producing a gate. The gate then takes some hoon. #### Accepts `a` is a `tang`, and is the sample of `+slog`. `(slog a)` takes some `hoon`. #### Produces The result of the hoon given to `(slog a)`, with `a` printed to the terminal. #### Source ```hoon ++ slog =| pri=@ |= a=tang ^+ same ?~(a same ~>(%slog.[pri i.a] $(a t.a))) ``` #### Examples ``` foo > ((slog leaf+"foo" ~) (add 1 1)) 2 ``` #### Discussion `slog` is intended to be put in the middle of a bunch of chained function calls that string a piece of data through them, so that an error message will be printed if there's one to print. --- ## `++mean` Crash and printf Ends the program and prints `a`, a tracing error message. #### Accepts `a` is a `tang`. #### Produces A crash, with `a` printed to the terminal. #### Source ```hoon ++ mean |= a=tang ^+ !! ?~ a !! ~_(i.a $(a t.a)) ``` #### Examples ``` > (mean leaf+"foo" ~) foo dojo: hoon expression failed ``` ---