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

0
votes
0answers
27 views

Context DocumentationSearch was not created - Why? (in Mathematica 10.4)

I try to look up Options of Plot3D and therefore I highlight this word in my notebook and press the key F1. It gives me a message ...
8
votes
2answers
147 views

FullForm with context for each symbol?

FullForm strips the context for any symbol that can be found on the Append[$ContextPath, $Context]: ...
1
vote
1answer
35 views

`$ContextPath` different on first run

When I run Quit, then the first time after that I evaluate $ContextPath I get ...
6
votes
1answer
80 views

How does Context work? [duplicate]

I thought when we type a symbol without specifying its Context, it will search all the Context in ...
6
votes
1answer
201 views

Where does a package have to be loaded?

I'm trying to solve a very tricky issue in my function. The function needs the NDSolve`FEM` framework. Here is a minimal example: ...
5
votes
1answer
66 views

Prevent autocompletion for symbols in contexts other than “`Private`”

I've been working on a Mathematica package (call it QuantumDot) that has become huge. Right now, all the back-end helper functions are in context ...
13
votes
2answers
196 views

Second argument of BeginPackage with nested package loading

I naively thought that the second argument of BeginPackage can simply be used to ensure the loading and availability in the ...
1
vote
1answer
56 views

Derivative in my package return 0

I'm writing my package (.m) in Mathematica and when I'll call the function returns 0 instead of right output. Here's my code: Package.m ...
4
votes
1answer
110 views

Can a package append its context to $DistributedContexts?

I am writing a package (for reference, this one) which I use extensively in parallel computations, and to lighten the coding load on the 'run-time' notebook, I want my package to sit on the ...
3
votes
1answer
57 views

Behavior of Remove inside a Package

I have a notebook containing (in a Code cell, Initialization Group) ...
16
votes
2answers
168 views

Global context seems to be shared between kernels when using Clear?

I am trying to understand the following behaviour, and determine if it's a bug in Mathematica 10. I am using Mathematica 10.3, and can't reproduce this behaviour under Mathematica 9. The test outlined ...
6
votes
2answers
96 views

How to store symbols in a package without being parsed?

I have a package file myPackage.m with the following content: BeginPackage["myPackage`"]; load[] := {a, b, c}; EndPackage[]; ...
5
votes
3answers
104 views

How can I pass replacement rules to a package-defined function and have it understand their context?

I am writing a package where I would like to be able to pass replacement rules to a function inside the package and have the function manipulate its symbols using those replacement rules. However, I'm ...
5
votes
1answer
113 views

Same name for functions in package and Global context

I am using a package that was written for Mathematica 3 while I am now working on Mathematica 8. I have issues with 2 functions in particular, Order and GraphComplement. They are a part of this ...
1
vote
1answer
28 views

Notation::gshadw warning when using Symbolize inside If

Somewhere in my init.m file I have the following code: ...
2
votes
1answer
103 views

Why must I specify the Global context for a symbol in a private package?

I have written two versions of the function below in a package. When I load the package and call the function, Why does the first version where the variable s has no explicit Context return the long ...
4
votes
1answer
75 views

Why does Information[]-Function (question mark) prepend additional contexts to $ContextPath?

I evaluated the following in Mathematica 10.2 with a refreshed kernel: ...
2
votes
1answer
44 views

Import variable assignments from external files into different contexts

(I use Mathematica 9.0.1 on OS X 10.10.5.) I have two text files. One is named file1.txt with the contents a = 4 b = 15 c = 23 ...
30
votes
3answers
384 views

How can I evaluate untrusted Mathematica code in a sandbox?

Is there any way to build a sandbox to evaluate untrusted Mathematica expressions in order to prevent them from having (malicious or accidental) harmful side effects? Context: I'm developing a system ...
2
votes
0answers
100 views

Shadowing issue with DeleteDuplicatesBy

I have been running a function in Mathematica 10 with the command, DeleteDuplicatesBy. The function was working great until one day I started to get an error with ...
3
votes
0answers
38 views

Context is not clearable and does not reload [closed]

I'm just going crazy with Mathematica Contexts as they absolute do not work as intended. Simple Example: Begin["TEST`"] Hello[s_]:=s Bye[s_]:=s End[] Now using ...
14
votes
1answer
248 views

Global` context not empty at startup in v10.2.0

Bug introduced in 10.2 and persisting through 10.2 or later Note that the analysis of this problem revealed a different problem than in Potential pollution of Global` context in fresh kernel (see ...
3
votes
2answers
110 views

Sections with unidirectionally shared variables

I have 2 sections is my notebook: ...
6
votes
1answer
135 views

When I run multiple Mathematica programs from terminal, are they supposed to use different Kernel?

Since I found that when I using notebook interface, I need to assign different kernels to different notebooks (if I want to run them at the same time), I wonder if I run those *.m files from terminal ...
7
votes
2answers
140 views

Inserting symbols' definitions during read time of the code

Let's say we've got a package: ...
13
votes
2answers
371 views

Why does leaving and re-entering a context lose values defined in that context?

I'm getting unexpected behavior when beginning a new context, leaving it, and then re-entering it. Specifically, when re-entering the context, symbols that had been previously defined in that context ...
3
votes
0answers
38 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: ...
5
votes
0answers
52 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 ...
5
votes
1answer
107 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: ...
6
votes
1answer
91 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
77 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. ...
5
votes
2answers
343 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
69 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 ...
12
votes
2answers
208 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 ...
3
votes
3answers
129 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 ...
3
votes
1answer
119 views

Using packages with symbols that have the same name

Let us suppose we have two packages: A and B. ...
13
votes
1answer
323 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 ...
14
votes
3answers
276 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 ...
10
votes
2answers
219 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 FrontEnd...
2
votes
1answer
77 views

Removing commands used before loading package

Original Question: I used the convert command before loading the Units package. Convert[20000. Feet, Mile] Since Convert isn'...
1
vote
2answers
83 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
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 ...
0
votes
1answer
303 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 ...
2
votes
1answer
82 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
98 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. ...
1
vote
1answer
88 views

Symbol resolution for contexts inside packages

Say I create $UserBaseDirectory/Autoload/MyPackage/init.m containing: ...
0
votes
1answer
654 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 ...
10
votes
0answers
158 views

Autocomplete of non-global functions

In Mathematica 9 and 10 they added autocompletion. Out of the box this works great, but when I set the CellContext to "Notebook" ...
14
votes
1answer
269 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
118 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: ...