Skip to main content

pattern_let_code

Function pattern_let_code 

Source
pub fn pattern_let_code(
    names: &[Box<str>],
    pattern: &Arc<QTerm>,
    value: &Arc<QTerm>,
) -> (Arc<QTerm>, Arc<QTerm>)
Expand description

The two terms a pattern-let rewrites to: the destructuring binder [a, b] that replaces the pattern quote, and the matching call qmatch_n(&*<pattern>, &<value>) that replaces the initializer.

The pattern is dereferenced explicitly (&*) because it is not always a method chain. A variadic pattern node that holds a metavariable expands to an accumulator block, { let mut b_ = ..; ..; b_.b() }, and in &{ .. } the &QTerm that qmatch_n expects flows into the block, which makes its Arc<QTerm> tail a type error that no deref coercion repairs. &* derefs the Arc the block evaluates to, whatever form it takes.