Yeah, I also like the label analogy. I think it helps clarify that y = x
doesn’t do anything other than associate the name :y
with the current value of x
.
The good news is that if you’re used to Python’s variable semantics, you should find that Julia’s behavior generally matches your expectations. In both Julia and python, doing y = x; y = z
never changes x in any way-- it just attaches the :y
label to a new value. Likewise in both Julia and Python, doing y[x] = z
results in a function call that looks something like “set the x
index of y
to value z
” and thus modifies the current value of y
.