Variables and scope
A name defined with := is stored on the worksheet and is
available to every region that evaluates after it. There is no
separate local scope for ordinary math.
Where a name is visible
Evaluation order is visual: rows top to bottom, then left to right in each row. See Evaluation order for how rows are grouped. A definition sitting below a use, or to the right on a later row, is not in scope yet.
If you use a name too early, the region reports
'name' is not defined. Move the assignment up, or left on the
same row.
Redefinition
A later := with the same name overwrites the value for
everything after that point. There is no shadow stack. If you assign to a
built-in name such as sin or pi, your value wins
from that region onward.
What can be a name
- Letters, digits, and underscores —
w,L_span,sigma_x. - Greek letters —
θ,σ_x. See Greek letters and symbols. - Dotted names such as
N_b.Rdfor code-style identifiers.
You cannot define a function with name(...):=. Calculeaf
reports that function definitions are not supported. Use a built-in from
Functions ▾, or write the expression out.
Other ways names enter scope
Lists and sliders inject their current values at their place in evaluation order. A 2D frame injects its result names when it sits in the sequence. Those names behave like assignments from that point down the page.