pub fn program_with_components(
depth: usize,
count: usize,
shared: bool,
) -> StringExpand description
count instantiations of a chain of components depth deep.
§16.10 states the components trade-off as a dilemma: “either the compiler inlines bodies into the parent’s template, multiplying template bytes and destroying per-component incremental compilation, or a call site becomes a dynamic hole with its own clone, degrading toward one clone per component.” Issue #209 asks which horn this compiler is on and what it costs, and neither question has an answer without a program whose component depth and count can be varied independently.
Each level declares one component whose body instantiates the next, so
the source is O(depth + count) lines while the fully expanded view is
depth × count bodies. A superlinear emission in either variable shows
up here and nowhere else in this file: program_with_depth nests
built-in elements, which the emitter has never had to expand.
shared is the other half of the question, and it is the half that
decides whether the bytes were avoidable. A component handed a literal
at each call site folds that literal into the markup, so no two copies
of its body are the same string and there is nothing a compiler could
have shared. A component reading one module-level signal has a hole
there instead, so every copy is byte-identical — and the bytes are then
a choice rather than a necessity.