CellContext
is an option for Cell which specifies the context to use for the evaluation of the contents of the cell.
Details


- The following settings can be given:
-
"context`" explicit context Notebook unique to this notebook CellGroup unique to this cell group Cell unique to this cell - The default setting is CellContext->"Global`".
- With CellContext->Cell, a unique default context is used for the current cell. This context is always different from the default contexts of all other cells, but stays the same for all evaluations done in the current cell.
- With CellContext->CellGroup, a unique default context is used that is shared between all cells in the nearest enclosing group that includes the current cell and any output generated from it.
- With CellContext->Notebook, a unique default context is used that is shared between all cells in the current notebook.
- CellContext effectively allows sequences of evaluations to be isolated from each other within a single Wolfram System session.
- By changing the default context using CellContext, values of session variables such as In, Out, and $Line are effectively localized.
- The setting for CellContext determines the default initial values for $Context and $ContextPath to be used when a cell is evaluated.
- The values of $Context and $ContextPath are taken to be local to the context defined by CellContext. Any modifications made to them will affect all cells with the same default context.
- Packages must typically be loaded separately in each default context generated by CellContext. The packages will not normally be visible across different default contexts.
- CellContext is often set at the level of stylesheets or complete notebooks rather than individual cells.
- Typical context names generated by CellContext->Cell are of the form Cell$n.
Examples
Basic Examples (1)
Examples in this documentation use a unique CellContext for each example group:
Wolfram Research (2007), CellContext, Wolfram Language function, https://reference.wolfram.com/language/ref/CellContext.html.
Text
Wolfram Research (2007), CellContext, Wolfram Language function, https://reference.wolfram.com/language/ref/CellContext.html.
CMS
Wolfram Language. 2007. "CellContext." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/CellContext.html.
APA
Wolfram Language. (2007). CellContext. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CellContext.html