Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
6 votes
4 answers
651 views

Expressions containing globally undefined symbols inside a function where they are defined

Consider the following code. f[a_,b_]:=x x=a+b; f[1,2] (* a + b *) From a certain viewpoint, one might expect it to return 3 ...
imakhlin's user avatar
  • 177
10 votes
4 answers
1k views

How to set Block local variables by code?

I need to create a user-defined Block function where the Block variables' values are defined by code. For example, imagine I ...
Murta's user avatar
  • 26.4k
57 votes
2 answers
2k views

How safe is the use of Block and Internal`InheritedBlock

For many questions on this site answers are given which suggest to use Block and, especially for more advanced topics, ...
Albert Retey's user avatar
  • 23.6k
32 votes
1 answer
964 views

Is the renaming mechanism of `With` flawed?

I'm confused about the renaming mechanism of With: ...
luyuwuli's user avatar
  • 2,814
3 votes
1 answer
430 views

Call Functions From File Without Modifying Context (Sandbox)

Let's say I have file named test.m containing test[arg1_] := ( Print[arg1];) What is the best technique for calling test like ...
William's user avatar
  • 7,655
4 votes
1 answer
528 views

ControlType -> None Vs. Module inside Manipulate (i.e. making everything local)

I'm building a program on another one made available in the Wolfram Demonstration Project. I've noticed that in the original code (working flawlessly) many variables were made local inside the ...
Luca M's user avatar
  • 1,079
9 votes
6 answers
956 views

How can you give a Module a context and have its local variables and Modules belong to that context?

What would be the best way to give a module its own context and have its local variables and Modules belong to that context?
17 votes
1 answer
541 views

Is the sharing of variables in Module/Block within Compile documented behavior?

Today I noticed something, I think for the first time. When used inside Compile variable values within Module (and ...
Mr.Wizard's user avatar
  • 273k
17 votes
1 answer
564 views

Modules that initialize themselves on first call

I use a lot of functions that extract a specific data item from a file with many data items. I want these functions to load data (slow) and return the item (fast) on first call, but just return the ...
George Wolfe's user avatar
  • 5,482
10 votes
1 answer
177 views

Is it possible to use the global definition of a symbol as part of its new local definition set in a Block?

Consider the following expression: Block[{Print = CopyToClipboard}, doSomething[]] Now all calls to Print from ...
Vladimir Reshetnikov's user avatar
5 votes
3 answers
238 views

Prevent iterator name from being confused with symbol passed into function body

I have a massive amount of code with lots of Table and Sum inside a Module. Each with their ...
QuantumDot's user avatar
  • 19.8k
5 votes
1 answer
637 views

How to avoid conflicts between local variable names and symbolic arguments in Block constructs?

I am using Block inside the definition of some recursive functions. If the Block definitions use short variable names, like ...
agravier's user avatar
  • 609