({{, (RefLink[CellContext, paclet:ref/CellContext]) 
is an option for (RefLink[Cell, paclet:ref/Cell]) which specifies the context to use for the evaluation of the contents of the cell.}})

OpenersNotesSection(Spacer1)Details

The following settings can be given:

The default setting is (RefLink[CellContext, paclet:ref/CellContext])->"Global`".

With (RefLink[CellContext, paclet:ref/CellContext])->(RefLink[Cell, paclet:ref/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 (RefLink[CellContext, paclet:ref/CellContext])->(RefLink[CellGroup, paclet:ref/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 (RefLink[CellContext, paclet:ref/CellContext])->(RefLink[Notebook, paclet:ref/Notebook]), a unique default context is used that is shared between all cells in the current notebook.

(RefLink[CellContext, paclet:ref/CellContext]) effectively allows sequences of evaluations to be isolated from each other within a single Wolfram System session.

By changing the default context using (RefLink[CellContext, paclet:ref/CellContext]), values of session variables such as (RefLink[In, paclet:ref/In]), (RefLink[Out, paclet:ref/Out]), and (RefLink[$Line, paclet:ref/$Line]) are effectively localized.

The setting for (RefLink[CellContext, paclet:ref/CellContext]) determines the default initial values for (RefLink[$Context, paclet:ref/$Context]) and (RefLink[$ContextPath, paclet:ref/$ContextPath]) to be used when a cell is evaluated.

The values of (RefLink[$Context, paclet:ref/$Context]) and (RefLink[$ContextPath, paclet:ref/$ContextPath]) are taken to be local to the context defined by (RefLink[CellContext, paclet:ref/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 (RefLink[CellContext, paclet:ref/CellContext]). The packages will not normally be visible across different default contexts.

(RefLink[CellContext, paclet:ref/CellContext]) is often set at the level of stylesheets or complete notebooks rather than individual cells.

Typical context names generated by (RefLink[CellContext, paclet:ref/CellContext])->(RefLink[Cell, paclet:ref/Cell]) are of the form (RefLink[Cell, paclet:ref/Cell])$n.

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Examples in this documentation use a unique (RefLink[CellContext, paclet:ref/CellContext]) for each example group:

Context[t]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Evaluator, paclet:ref/Evaluator])  ▪  (RefLink[$Context, paclet:ref/$Context])  ▪  (RefLink[CellProlog, paclet:ref/CellProlog])  ▪  (RefLink[CellEpilog, paclet:ref/CellEpilog])  ▪  (RefLink[Dialog, paclet:ref/Dialog])  ▪  (RefLink[Begin, paclet:ref/Begin])  ▪  (RefLink[BeginPackage, paclet:ref/BeginPackage])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Namespace Management, paclet:guide/NamespaceManagement])}, {▪(RefLinkPlain[Evaluation Options in Notebooks, paclet:guide/EvaluationOptionsInNotebooks])}, {▪(RefLinkPlain[Stylesheets, paclet:guide/Stylesheets])}, {▪(RefLinkPlain[Package Development, paclet:guide/PackageDevelopment])}, {▪(RefLinkPlain[Package Bulletproofing, paclet:guide/PackageBulletproofing])}})}})