on 883cb21 help sign in
83 lines 1.2 kB history raw
1+++
2title = "5c: Compiler Backend & Prettyprinter"
3weight = 45
4template = "doc.html"
5+++
7(To be fully documented)
9## `++slog`
11Deify printf
13Prints stack trace `a` if the stack trace isn't null, then produces the other
14input. `+slog` first takes `a`, producing a gate. The gate then takes some hoon.
16#### Accepts
18`a` is a `tang`, and is the sample of `+slog`.
20`(slog a)` takes some `hoon`.
22#### Produces
24The result of the hoon given to `(slog a)`, with `a` printed to the terminal.
26#### Source
28```hoon
29++ slog
30 =| pri=@
31 |= a=tang ^+ same
32 ?~(a same ~>(%slog.[pri i.a] $(a t.a)))
33```
35#### Examples
37```
38foo
39> ((slog leaf+"foo" ~) (add 1 1))
41```
43#### Discussion
45`slog` is intended to be put in the middle of a bunch of chained function
46calls that string a piece of data through them, so that an error message will be
47printed if there's one to print.
49---
51## `++mean`
53Crash and printf
55Ends the program and prints `a`, a tracing error message.
57#### Accepts
59`a` is a `tang`.
61#### Produces
63A crash, with `a` printed to the terminal.
65#### Source
67```hoon
68++ mean
69 |= a=tang
70 ^+ !!
71 ?~ a !!
72 ~_(i.a $(a t.a))
73```
75#### Examples
77```
78> (mean leaf+"foo" ~)
79foo
80dojo: hoon expression failed
81```
83---