Variables (bindings)
The two kinds of binding — `=` for locals and `<-` for reaching out of a function.
Fluxon has two kinds of binding, and they do different things (which is why having two does not violate the canonical rule). The model is Python's: an assignment is local to the current function, and there is no immutability — any name can be re-bound.
= — bind a local (the default)
x = 10
name = "Aziza"
x = 20 # re-binding is fine — = just updates x= binds in the current function. if/each/match blocks are
transparent (they open no new scope), so the accumulator pattern reads naturally:
total = 0
each n in [10 20 30]
total = total + n # updates the same `total`
# total == 60Inside a function, = always makes a local — it never touches an outer or
global variable of the same name (shadowing, like Python).
<- — reassign, reaching out of the function
Use <- to write to a variable that lives in an enclosing function or at the
top level — it crosses the function boundary (closure capture):
counter <- 0
inc = \n ->
counter <- counter + n # writes the OUTER counter, not a local
inc 5 # counter == 5Rule
Use = for a normal (local) value. Reach for <- only when a function must
write to a variable defined outside it — that is the one thing = will not do.
When you see <-, you know "this reaches out and changes something shared".