substitute_with_context
Stable function · Expressions
Tier: stable · Kind: function · Topic: Expressions
| Julia | TypeScript | Python | Rust | Go |
|---|---|---|---|---|
| not exported | not exported | not exported | substitute_with_context | SubstituteWithContext |
Julia
Julia does not export this function.
TypeScript
TypeScript does not export this function.
Python
Python does not export this function.
Rust
pub fn substitute_with_context(expr: &Expr, substitutions: &HashMap<String, Expr>, context: &ScopedContext) -> Expr
Substitute variables in an expression with scoped reference resolution (esm-spec §2.3.3).
Resolution order per variable leaf: exact-name substitution, then scoped
resolution of the name via context (substituting the resolved name if it
has a binding, else rewriting the leaf to the resolved name), else the
leaf is left unchanged. Traversal and metadata preservation are identical
to substitute
.
Go
func SubstituteWithContext(expr Expression, bindings map[string]Expression, file *ESMFile, currentSystem string) (Expression, error)
SubstituteWithContext performs variable substitution in a SCOPE CONTEXT: the (file, currentSystem) pair against which a dotted binding key like “OtherModel.x” is resolved. Canonical substitute_with_context (API_SPEC.md §8 item 9) — the family was spelled *WithScoped here and *_with_context in Rust, which names the same context a ScopedContext.
Passing a nil file and an empty currentSystem disables dotted-name resolution and makes this exactly Substitute.