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

3
votes
0answers
35 views

Cross referencing symbols in different packages [duplicate]

I have problems with name space shadowing which I do not know how to resolve. I have two packages which depend on each other. Here is example of two files fooPackage.m: ...
10
votes
2answers
180 views

Why is a symbol still found after changing its context?

It seems that we can change the context of symbols: In[1]:= x = 1 Out[1]= 1 In[2]:= Context[x] = "foo`"; But then x is still ...
2
votes
1answer
110 views

Symbol not added to context

I have run into a problem that is currently stumping me. I'm running a WebMathematica server, and am trying to create a package to use on one of the pages. However, when I load the package, it appears ...
5
votes
0answers
43 views

How is CellContext->CellGroup supposed to work?

After reading the documentation on the subject, I still cannot get CellContext->CellGroup to work. Here's a simple example. (Unfortunately, I cannot easily ...
8
votes
2answers
611 views

How to properly handle mutual imports of multiple packages?

I'm new to the mathematica platform and I am developing a simulation framework as my first exercise and have been tearing my hair figuring how to make packages interact with each other. Ill explain a ...
5
votes
1answer
86 views

Naming conflicts with Dummy variables in several packages conflicts

I'm using several packages in a notebook. In each packages there is functions defined with dummy variables. When I load the several packages in my session, i've got a warning message: ...
5
votes
1answer
51 views

Update/refresh notebook variable color on clear

By default, Mathematica displays variable names already assigned as black while new variables are displayed in blue. When executing Clear["Global`*"], variables ...
0
votes
1answer
44 views

How can I use private variables in different ways

How can I use some private variables/symbols in another sub contexts in different ways. Note: Please do not use code Cell Style for testing the codes. ...
15
votes
4answers
319 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 ...
-5
votes
1answer
122 views

Exporting data from different notebooks to a common file

I am doing some calculations from different notebooks. I need to export the results from all those notebooks in columns of the same file, like a1 b1 c1 a2 b2 c2 a3 b3 c3 . . . where a, b ...
3
votes
2answers
75 views

Rewriting symbol context?

I have some code that uses a list of replacement rules to inject values (physical constants for different materials) into a more complicated expression. This is convenient since I can tweak the values ...
5
votes
2answers
161 views

Package Loading: How to get rid of Needs::nocont?

I am trying to create a documentated application inside FileNameJoin[{$UserBaseDirectory, "Applications"}] I obviously dont fully understand the concept of the ...
4
votes
0answers
63 views

Variable not assigned to correct Context [duplicate]

I am trying to understand Mathematica's Context, but I do not understand why the short name of the variable defined in the temp` context (x) returns the Global definition. I am following the section ...
55
votes
6answers
3k 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 ...
3
votes
1answer
81 views
8
votes
1answer
156 views

Context of localised (dynamic) symbols

When you localise a symbol with Module, the created unique symbol is usually in the current context. There seems to be an exception to this which has further ...
1
vote
0answers
110 views

NMaximize with matrix input

I defined function f[x_, fixed_] := {...}. Here x is an $M\times N$ matrix. I want to maximize $f$ with respect to $x$. I have ...
9
votes
2answers
150 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 ...
21
votes
2answers
492 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 ...
3
votes
2answers
122 views

ContextPath and autocompletion with subpackages

I'm developing a larger package which includes several subpackages. My problem is, that I can't introduce the symbols in the subpackages to the autocompletion by loading the main package, but by ...
9
votes
2answers
174 views

What are the purposes of functions in FrontEnd` context which are duplicates of those in System`?

I noticed that for notebook-related heads, there are usually a pair of same functions, one in System context, another in ...
1
vote
2answers
72 views

Set Options on a system function has effect on all notebooks

I have a Notebook A with default context: "Unique to this Notebook". In there I set an option: SetOptions[Interpolation, InterpolationOrder -> 1] This has ...
0
votes
1answer
92 views

Symbol appears in multiple contexts when load two packages with unique function names

I have two packages "packageA" and "packageB". The function names across packageA and packageB are unique. No two functions have the same name. When I issue the ...
0
votes
0answers
37 views

Is it possible to have a function with non-global parameters? [duplicate]

If I have functions in two packages that have parameters such as length_, width_ and height_; is there any way to have both packages loaded without generating messages such as "Symbol length appears ...
2
votes
1answer
62 views

Button action preventing parallel execution?

I couldn't find a better title, so I'll jump straight to the example! There is this long list of slow jobs to be executed in a parallel way, at the press of a button: ...
1
vote
0answers
90 views

Strange Behavior with Private Contexts in 10.0.1

I have noticed the following weird behavior when creating Private Context in V 10.0.1, a behavior not present in V 10.0.0. ...
8
votes
3answers
589 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 ...
13
votes
1answer
207 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"} ...
1
vote
1answer
87 views

Symbol resolution for contexts inside packages

Say I create $UserBaseDirectory/Autoload/MyPackage/init.m containing: ...
0
votes
1answer
297 views

A symbol occurs in more than one context:one of the definitions is shadowed

I started Mathematica 10 and run as the tutorial says: trainingset = {1 -> "A", 2 -> "A", 3.5 -> "B", 4 -> "B"}; c = Classify[trainingset] but the ...
7
votes
2answers
160 views

How to define UpValues in a different context from within a package

I'm trying to create a function (in a package) to import a lot of data and create a symbol with UpValues to return specific results about the data. I've got it working fine in a regular notebook, but ...
13
votes
1answer
417 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 ...
1
vote
1answer
67 views

how to make cells independent with each other in notebook

If we open DocumentationCenter and then run code, we will find that the Cells are independent from each other. For example: ...
10
votes
1answer
172 views

Importing an mx file into a context

Consider the following simple code which dumps the global context: var = 5; DumpSave["test.mx", "Global`"]; Now, in a new notebook, I would like to import var in ...
1
vote
0answers
95 views

Auto-complete for user defined functions [duplicate]

If I define a symbol in Mathematica, it doesn't show up in the autocomplete list that works for symbols in System. Test code: ...
8
votes
2answers
213 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 ...
14
votes
2answers
180 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, ...
15
votes
2answers
198 views

How to find the package file that stores a certain symbol?

Is it possible to figure out in what file a certain packaged symbol lives in (assuming there is no shadowing between multiple identical symbol names)? I would like to have a function that if, given a ...
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 ...
9
votes
2answers
347 views

Why doesn't DumpSave work for elements created within a local notebook context?

I recently noticed that when dealing with notebooks with local context, I cannot successfully DumpSave variables, or, rather, when I call ...
0
votes
0answers
92 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 ...
11
votes
3answers
205 views

Creating a custom context with a Hold construct

I'm trying to create a function "InContext" to execute a piece of code inside a certain context (and to return the result of evaluating that piece of code). One approach is to place the code inside a ...
1
vote
1answer
74 views

Can kernel-specific variables be accessed from stylesheets?

I'm trying to create a modified version of the Default.nb StyleSheet that adds a docked cell to act as a status bar along the top of every notebook to display some ...
10
votes
1answer
155 views

Is there a way to find out who is importing a package?

After calling some functions, if I look into $ContextPath, I can see that JLink` is in there. Is there a way to find out what ...
32
votes
1answer
1k 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 ...
1
vote
2answers
97 views

Given a list of context names, how can I access all the variables with the same name across all those contexts?

I'm looking to access variables in different contexts. The contexts are stored in a list labeled contexttable. Each context, of course, is a string. Is there any ...
2
votes
1answer
169 views

WebServices context problem

I'm using two web services from the same host: Earth Orientation Center I can get each one to work on a fresh kernel but I cannot get both of them to work during the same instance of the kernel. I ...
2
votes
2answers
95 views

How to make a function work on symbols in a specific context

Let us say we have two sets of symbols $(x, y, z)$ with the same names that live in two different contexts: ...
2
votes
1answer
247 views

Errors when using ParallelTable inside a package

I'm developing a package that contains a function that requires evaluation of an expensive Table, so I use ParallelTable ...
6
votes
0answers
84 views

Does one need to be careful about loading multiple (many) contexts or packages in the same session?

I have a number of large pieces of precomputed data which I am considering putting into individual packages in order to load them (via DeclarePackage) and unload ...