Linked Questions

457
votes
37answers
102k views

What are the most common pitfalls awaiting new users?

As you may already know, Mathematica is a wonderful piece of software. However, it has a few characteristics that tend to confuse new (and sometimes not-so-new) users. That can be clearly seen from ...
37
votes
4answers
982 views

What is the difference between Dynamic[x] and Dynamic[ h[x] ] for DynamicModule variables?

Bug introduced in 9.0 or earlier and persisting through 12.0 In 11.3 it is even worse. An example from the accepted answer with a Slider is now broken too: ...
45
votes
1answer
2k 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 ...
18
votes
3answers
648 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 ...
14
votes
3answers
379 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: ...
14
votes
2answers
469 views

Is Mathematica's lexical scoping broken?

Why do these two lines output different things (b and 0, respectively)? Is it a bug? ...
5
votes
1answer
258 views

Why do functions defined with SetDelayed and Function behave differently in callbacks?

It seems to me that functions defined using a simple pattern and SetDelayed (the usual way to define a "function") should be equivalent in all respects to functions ...
5
votes
2answers
197 views

Conflict with variables in pure functions

Consider the following snippet of code. Clear[f, g] f[x_] := Function[{i}, x]; g[h_] := Module[{Z}, Z[i_] := Print[h]; Print[h]; Z[1]; ]; When ...
2
votes
2answers
124 views

DynamicModule Initialization is not executing when expected?

...
2
votes
1answer
130 views

Why is my variable Lambda defined but not the others?

I would like to understand why in the following code, my variable Λ is recognized by the system but not n. In fact for me ...
0
votes
1answer
146 views

How to avoid namespace leaks?

Below is a toy package that illustrates what I mean by "namespace leaks". ...