Version: dev

substitute_with_context

Stable function · Expressions

Tier: stable · Kind: function · Topic: Expressions

JuliaTypeScriptPythonRustGo
not exportednot exportednot exportedsubstitute_with_contextSubstituteWithContext

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 .

Source · Rust docs

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.

Source · Go docs