Context¶
Status: Stable
documented, exercised by the test suite and/or worked examples, with no known limitations recorded.
Description¶
Context[] gives the current context ($Context).
Context[sym] gives the context in which sym resides.
Context["name"] gives the context of the symbol named "name" if it exists.
Examples¶
No verified examples yet for this function.
Implementation notes¶
builtin_context (src/context.c) has three forms. Context[] returns context_current() (the g_current string, default "Global").Context[sym]/Context["name"](the symbol form is held —ATTR_HOLDFIRST) report the symbol's context: if the name already carries a backtick prefix it is peeled off and returned viacontext_prefix_len; otherwise the symbol is looked up withsymtab_lookupand reported as"System" when it is a builtin (def->builtin_func != NULL), else "Global". An unknown string-form name emitsContext::notfoundand leaves the call unevaluated; an unassigned bare symbol defaults to"Global".
Attributes: HoldFirst, Protected.
Implementation status¶
Stable — documented, exercised by the test suite and/or worked examples, with no known limitations recorded.
References¶
- Source:
src/context.c - Specification:
docs/spec/builtins/scoping-constructs.md
Notes & additional examples¶
Worked examples¶
Notes¶
Context[] returns the current context (the same value as $Context), while Context[sym] returns the context in which a symbol lives — built-ins such as Sin reside in "System"`.