Linked Questions

550 votes
37 answers
132k 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 ...
40 votes
4 answers
1k 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: ...
Kuba's user avatar
  • 137k
51 votes
1 answer
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 ...
owler's user avatar
  • 613
20 votes
3 answers
1k 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 ...
Kuba's user avatar
  • 137k
16 votes
3 answers
633 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: ...
Joel Klein's user avatar
  • 5,225
14 votes
2 answers
550 views

Is Mathematica's lexical scoping broken?

Why do these two lines output different things (b and 0, respectively)? Is it a bug? ...
user541686's user avatar
  • 1,317
5 votes
1 answer
370 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 ...
ibeatty's user avatar
  • 2,543
5 votes
2 answers
243 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 ...
anon's user avatar
  • 53
2 votes
2 answers
156 views

DynamicModule Initialization is not executing when expected?

...
Edmund's user avatar
  • 42.4k
2 votes
1 answer
223 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 ...
StarBucK's user avatar
  • 2,164
0 votes
1 answer
202 views

How to avoid namespace leaks?

Below is a toy package that illustrates what I mean by "namespace leaks". ...
kjo's user avatar
  • 11.7k
6 votes
1 answer
89 views

Context Manipulation within Scoping Constructs

In the following the full context form of Test is not required as "Aaa`" is added to ...
Ronald Monson's user avatar