15 questions linked to/from Is the renaming mechanism of With flawed?
1 vote
103 views

### Why does With return a temporary symbol? [duplicate]

Why does With[{x0 = 1, y0 = 2}, f[x_] = a + b x /. First[ Solve[{y0 == a + b x0, b == 0.1}, {a, b}]]] evaluate to ...
• 4,225
19k views

### What are the use cases for different scoping constructs?

Mathematica includes three functions that I know of which can be used to effectively (if not actually) define a variable and give it a value within a local scope: ...
• 4,961
3k views

### Enforcing correct variable bindings and avoiding renamings for conflicting variables in nested scoping constructs

Using global variables the following turns an "expression" into a Function: expr = 2 x; Function[x, Evaluate[expr]] Of course ...
• 4,034
1k views

### I define a variable as local to a module BUT then the module uses its global value! Why?

I have a question about modules and local variables. Here's my example: h = 5; Module[{a, h}, a[h_]= h^2; a[4]] (*Out[2] = 25*) I expected the module to ...
• 323
438 views

### Strange behavior with Cases and Position with SetDelayed

I feel like I must be missing something simple and obvious here, but this has me scratching my head. This works as expected: ...
• 1,783
1k views

### Why doesn't b = a; f[a_] := b; f[2] return 2?

As the title asks, why does b = a; f[a_] := b; f[2] evaluate to a rather than 2?
• 67.5k
456 views

### Rule rewriting behavior

This is kind of meta-programming attempt. Below are two snippets: Snippet 1: ...
• 1,345
485 views

### Variable scoping in Module

I don't understand why $a$ and $b$ are not local in the following code: ...
• 4,239
200 views

### Why does Block reset Attributes?

Not even "formal symbols" such as \[FormalX] are guaranteed to always be symbolic. Their Protected argument is forgotten when ...
• 5,739
196 views

### Is Function broken is this example?

This program f[x_] := g[Function[a, x]]; g[fn_] := Module[{h}, h[a_] := fn[a]; h[0]]; f[999] returns Function[0, 999][0] but ...
92 views

### Antiderivative of a piecewise function evaluates wrong inside a subroutine

It's very helpfull to use antiderivative of a given function in the form Derivative[-1][fun][t]! Here my example with a simple piecewise function: ...
• 55.1k