Module print

Module print 

Source
Expand description

The printer — one Node tree, two surfaces.

docs/02-syntax.md §2.2: “beck fmt --sexpr orders.beck emits the canonical Lisp form. beck fmt --py orders.sx emits the Python form.” §2.8 asks for it early because “every later phase uses it”: macro expansion dumps, beck ast, and the error renderer all print Nodes.

Round-tripping is lossless modulo formatting: parse(print(parse(src))) is structurally equal to parse(src), which is the property tests/roundtrip.rs asserts over the corpus.

Functions§

to_python
The Python surface. This is what beck fmt writes, and §2.6’s style rules (“snake_case values, PascalCase types … enforced by beck fmt”) are applied by the formatter, not here: this function prints faithfully, so that printing an already-renamed tree is idempotent.
to_sexpr
Canonical S-expressions, one line. The notation the sketch is written in.
to_sexpr_pretty
Canonical S-expressions, broken across lines where a form is long.