Example one:
This is said in the documentation
Block localizes values only; it does not create new symbols
I don't understand the previous sentence
ClearAll["Global`*"];
Block[{x}, x]
Block[{x}, Print[x]]
Example two:
This is an example of the documentation, but if one of x
or y
is global the example does not work
ClearAll["Global`*"];
Block[{f = Sin[x + I y]},
ParametricPlot[Evaluate[{Re[f], Im[f]}], {x, -Pi, Pi}, {y, -2, 2}, Mesh -> 10]]
Example three:
I would like the Block
to work regardless of whether x is global or not
ClearAll["Global`*"];
Block[{x},
TraditionalForm@TextCell[Column[{
Row[{x, " = ", 5}] (*I want x to always be a symbol*)},
Spacings -> 0.5], "Text", FontFamily -> "Palatino", FontSize -> 18] ]