Questions about contexts, which are used in Mathematica to organize defined symbols and avoid conflict between symbols that would otherwise have the same name. They are created when packages are loaded.

learn more… | top users | synonyms

50
votes
5answers
2k views

What is the most convenient way to read definitions of in-memory symbols when we don't have the source files? (Spelunking tools)

Note: I put Simon's implementation on GitHub. Contributions welcome! When trying to read the definition of already defined (package or built-in) symbols using ...
23
votes
3answers
1k views

How to load a package without naming conflicts?

This question applies to any package, but I encountered this problem while working with graphs. There are symbols in the Combinatorica package (such as ...
31
votes
1answer
971 views

Local variables in Module leak into the Global context

From the Mathematica documentation on Module: Module allows you to set up local variables with names that are local to the module. But after using ...
13
votes
1answer
394 views

Is it possible to use Begin and End inside a Manipulate?

May be someone can explain why I can't use Begin["context`"] and End[] inside a Manipulate ...
20
votes
1answer
2k views

Why are some function names red?

I need to evaluate Needs["GraphUtilities`"] before I can use functions such as GraphPath[]. When I do so, some functions get ...
8
votes
1answer
3k views

How do I create and use Mathematica packages?

I have created a package following the tutorial in Mathematica 8 virtual book. However this tutorial is quite, let's call it, "short". I have a TestPackage.m file: ...
20
votes
2answers
455 views

Context unique to each group at a specified level

Are there any new tools in v10 that might be applicable to this problem? Recent versions of Mathematica provide the option of having a unique $Context for each ...
13
votes
1answer
201 views

Potential pollution of Global` context in fresh kernel

Bug introduced in 10.0.0 and fixed in 10.0.1 If I evaluate, with a fresh kernel Names["Global`*"] I get {"rhs", "z"} ...
11
votes
2answers
204 views

Globally loading packages while using a CellGroup as the default context

I have a notebook I wish to set up where the sections are conceptually related to each other. But, I wish to isolate them from each other programmatically, so that they do not interfere with one ...
7
votes
6answers
599 views

How can you give a Module a context and have its local variables and Modules belong to that context?

What would be the best way to give a module its own context and have its local variables and Modules belong to that context?
13
votes
4answers
627 views

Strategies for avoiding and handling shadowing

When dealing with namespaces in Mathematica (BeginPackage, $ContextPath ...) one is unavoidably confronted with the problem of ...
12
votes
2answers
234 views

Result about Context is inconsistent with the description of “Power Programming with Mathematica”

x = 5; temp`x = 6; Begin["temp`"] {x, Global`x, temp`x} The result in my Mathematica session is {5,5,6}, but it's ...
6
votes
3answers
259 views

Scope within Context

To define some package-wide functions/variables, what approach is recommended? I tried to use contexts with the Begin function, but this failed: ...
13
votes
2answers
167 views

How to find out what files are touched when Get is called?

Is there a way to capture all package files touched whenever a package is called via Get, Needs, ...
7
votes
3answers
488 views

How can I make private functions inside packages

I want to make private functions.for that purpose,I wrote the following code. BeginPackage["Test1`"] Begin["`Private`"] function1[x_]:=x End[] EndPackage[] I ...
8
votes
2answers
201 views

The introduction for Context in Wagner's book is out of date? [duplicate]

In Section 8.1.1 (P230 of the book, P249 of the PDF) of Wagner's book, the following example is shown: x = 5; temp`x = 6; Begin["temp`"]; {x, Global`x} The ...
5
votes
2answers
200 views

Delete contexts from a string representation of a symbol

I want to delete the string representing the context of a symbol. For info I need such a functionality in my ShowIt function defined here I'd like to know how I ...
9
votes
2answers
117 views

How does $CellContext` work?

The only official info about $CellContext` I was able to find is: placeholder for the context of a symbol inside Dynamic ...
7
votes
1answer
150 views

Organizing similar datasets using Contexts or otherwise

I often import several long time series to analyze something about a city. When I have multiple cities, I use contexts. As a simple example, ...
8
votes
2answers
184 views

For any symbol, how can I get the full context-qualified name of the symbol as a string?

I'd like to have a function, whether built-in or not, that when given a symbol, whether bound to a value or not, returns a string giving the context and name of the symbol. Example: ...
3
votes
1answer
145 views

automatically add Global` to $ContextPath for all notebooks when using CellContext->Notebook

I have some definitions in my init.m. E.g. my init.m contains this: ...
0
votes
0answers
77 views

Setting individual CellContext for each notebook loses autocomplete suggestions

I'm running Mathematica 9.0.1 under OS X. In order to have separate contexts for each of my notebooks, I used the instructions in the last part of the accepted answer from the following link: Is ...