contribution
Stable type · Other
Tier: stable · Kind: type · Topic: Other
| Julia | TypeScript | Python | Rust | Go |
|---|---|---|---|---|
Contribution | Contribution | Contribution | Contribution | Contribution |
Julia
struct Contribution
Contribution(expr::ASTExpr, origins::Vector{TermOrigin})
Contribution(expr, origins)
Contribution(expr, origins)
One summand of a flattened equation’s right-hand side, with its authors.
origins is non-empty and deduplicated in first-appearance order for every
equation flatten produces. It has more than one entry only where a
non-additive merge (a multiplicative couple, or an operator_compose
translate factor over a multi-contribution equation) collapsed several
contributions into one indivisible expression. An EMPTY origins means “author
unknown”: the keyword copy constructor FlattenedSystem(flat; equations = eqs)
produces it when a caller replaces the equations without their contributions.
TypeScript
interface Contribution {
expr: Expression;
origins: TermOrigin[];
}
One summand of a flattened equation’s right-hand side, with its authors.
origins is deduplicated in first-appearance order. It has more than one
entry only where a non-additive merge (a multiplicative couple, or an
operator_compose translate factor applied to a multi-contribution
equation) collapsed several contributions into one indivisible expression.
Flatten never produces an empty origins; an equation built outside flatten
may carry one, meaning “author unknown”.
Python
class Contribution
Contribution(expr: Expr, origins: list[TermOrigin])
One summand of a flattened equation’s right-hand side, with its authors.
origins is non-empty and deduplicated in first-appearance order. It has
more than one entry only where a non-additive merge (a multiplicative
couple, or an operator_compose translate factor applied to a
multi-contribution equation) collapsed several contributions into one
indivisible expression. Provenance lives here, beside the expression tree,
never on a node: expr is an ordinary expression and compares, hashes and
canonicalizes as one.
Rust
pub struct Contribution {
pub expr: Expr,
pub origins: Vec<TermOrigin>,
}
One summand of a flattened equation’s right-hand side, with its authors (esm-libraries-spec §4.7.5, “Per-term provenance”).
origins is deduplicated in first-appearance order, and non-empty except
on an equation assembled without provenance (origin unknown). It has more
than one entry only where several contributions collapsed into one
indivisible expression: a non-additive merge (a multiplicative couple, or
an operator_compose translate factor applied to a multi-contribution
equation), or a caller’s edit to a right-hand side the list no longer sums
to (FlattenedSystem::equation_contributions). Provenance lives here,
beside the expression tree, never on a node, so expr compares, hashes and
interns as any expression.
Go
type Contribution struct {
Expr Expression `json:"expr"`
Origins []TermOrigin `json:"origins"`
}
Contribution is one summand of a flattened equation’s right-hand side, with its authors.
Origins is deduplicated in first-appearance order. It has more than one entry only where a non-additive merge (a multiplicative couple, or an operator_compose translate factor applied to a multi-contribution equation) collapsed several contributions into one indivisible expression. Flatten never produces an empty Origins; an equation built outside flatten may carry one, meaning “author unknown”.