RosettaCodeData/Task/Scope-modifiers/Mathematica/scope-modifiers.math
Ingy döt Net b83f433714 tasks a-s
2013-04-10 23:57:08 -07:00

19 lines
317 B
Text

Module -> localize names of variables (lexical scoping)
Block -> localize values of variables (dynamic scoping)
Module creates new symbols:
Module[{x}, Print[x];
Module[{x}, Print[x]]
]
->x$119
->x$120
Block localizes values only; it does not create new symbols:
x = 7;
Block[{x=0}, Print[x]]
Print[x]
->0
->7