Context

 

Context[] returns the name of the CurrentContext.

 

A ContextName is a String which must always end with a ContextMark.

 

Context[Sequence] is an ordered List of full ContextNames beginning with the CurrentContext.

 

The Context[Sequence] defines the lexical environment.

 

Context[{"curCntxtName`", "cntx1`, "cntx2`", ...}, namedExpr1, namedExpr2, ...]

...declares  namedExpr1 and then namedExpr21,  and so on, in the Context "curCntxtName`".

The List in the first argument above is the Context's ContextSequence.

This is called a ContextDeclaration.

 

Context["curCntxtName`", expr1, expr2, ...] declares  expr1 and then expr2,  and so on, in the Context, "curCntxtName`", importing the preexisting environment as the secondary lexical environment





Context[Tally] returns a Sequence or all active Contexts.
Context["cntxtNam`"]Tally returns each Name in the Context, "cntxtNam`".


Context[]Tally returns each Name in the current Context.



 

 

See English definition of "context".

 

 


"Context" defines the environment.

 

Everything is Named and Reckoned in some Context.

 

(1)                    Context[]

 

... returns the name of the CurrentContext. 

This is not a proper Name, but rather a String, understood to identify the CurrentContext.


All Contexts are identified by Strings.
Such a name is sometimes called a ContextString (and should not be confused with Names).

 

When a Name is interpreted, the local Context is the first place searched for the Name's assignment. 

If it is not assigned locally, the Name is searched for in the remaining elements in the ContextSequence

The ordered elements in the ContextSequence specifies the search order. If the Name is not found, it is created in the local Context.

 

 



ContextName & subContexts



A ContextName is not a Name.  A ContextName must be written in double quotes, and must always end with a ` mark (sometimes called the "backquote). Within this document, the ` Character is called the ContextMark.

A subContext shares the  same ContextName prefix as its containing Context

For example, the `Logic` subContext is a subContext in Grok32`.

            The FullName for the Keyword, And, is "Grok32`Logic`And.  

 

When a ContextName, begins with the ContextMark, it is understood to be a subContext to the Context where it was encountered.  For example, `Logic` is a subContext to Grok32`.

 

 



ContextSequence



Context[Sequence] is an ordered List of full ContextNames beginning with the CurrentContext

The Context[Sequence] defines the lexical environment.

 

Suppose sym could be a recognized Grok32` Name (symbol). 

Reckon parses Expressions into Names with argument sequences.

 

This is how an arbitrary String, sym, is Reckoned (parsed, then (recognized | created)):

� If a symbol is not found in the CurrentContext, the elements of Context[Sequence] are searched in sequence to find a Context containing the symbol.

� If sym is not found in any context along the Context[Sequence], then sym is a NewName created in the CurrentContext.

 

 



Context Declaration

 


(2)        Context[{"curCntxtName`, "cntx1`, "cntx2`, ...},

                        namedExpr1,

                        namedExpr2,

                        ...]

 

...declares  namedExpr1 and then namedExpr2,  and so on, in the Context "curCntxtName`....�  Each Named Expression, "namedExpr1, namedExpr2, , is an assignment such as:  Name[elicitation, expr].

The lexical environment is specified by the ContextSequence defined in the first parameter above (E.G. {"curCntxtName`, "cntx1`, "cntx2`, ...}).  This type of elicitation unambiguously specifies the lexical environment. By contrast,

 

(3)        Context["curCntxtName`,

                        expr1,

                        expr2,

                        ...

            ]

 

...declares  expr1 and then expr2,  and so on, in the Context, "curCntxtName`, importing the preexisting environment as the secondary lexical environment.  The Context created by (2) takes its ContextSequence from the environment wherein (3) was evaluated, and prepends the ContextSequence with "curCntxtName`".


 



Context Tally



(4)            Context[Tally]


...returns a Sequence or all active Contexts.



(5)            Context["cntxtNam`"]Tally


...returns each Name in the Context, "cntxtNam`".


Finally, there is a short form that selects Names in the CurrentContext:

(6)            Context[]Tally

...returns each Name in the current Context.
Thus, while (4) and (6) have rather similar forms,
�  (4) returns a Sequence of ContextStrings, while
�  (5) and (6) each return a Sequence of Names.





English definition of "context"

 

context n.

1. The weaving together of words in language; also, the discourse or writing so produced. Obs.

2. The part or parts of a discourse preceding or following a "text" or passage or a word, or so intimately associated with it as to throw light upon its meaning.

3. Associated surroundings, whether material or mental.

4. Obs. a Coherence in discourse.  b Contexture.

5. Archael.  Surroundings; things or conditions which serve to date or characterize a specified article.

 



Grok32`

(c) 2004-2008 by
John Van Wie Bergamini.

Hosted by www.Geocities.ws

1