Rick said:
Yes, you're missing the distinction between a variable which
references a sequence of objects over time, and the objects it
references.
a = 1
a = 2
Does NOT change 1 to 2.
Hmm, I guess I wasn't clear, because that was my point (and another
person also didn't understand me). My point was that n can be
destructively altered by assignment, but its value (1) cannot be. So
even though a particular matrix (as a value) is immutible and unique, a
matrix (as a concept, viz., the data structure, it's reference) need
not be. Given matrix r, represented simply as a dimensional array:
r = [
[1, 1, 1],
[1, 1, 1],
[1, 1, 1]
]
What would be the difference between:
n = 1
n = n + 1
And:
r[1][1] = r[1][1] + 1
You have a new matrix (as a value), so you're not violating identity,
but you keep the same data structure by destructive assignment ([]=),
rather than creating a new one with the new value in row 1, column 1.
That can easily be added, as was mentioned above, but the rationale for
it not being there is what doesn't make sense to me. The rationale is
that a matrix (as a value) is immutable and unique; but so are regular
integers and that doesn't hinder their "container" (i.e., a reference)
from being mutable. We don't have to construct a new variable every
time we transform an integer to a different integer; why should a
member of matrix be any different and require a new matrix to be
constructed rather than allowing the reference to the member to be
destructively modified?
Anyhow, I don't really care if []= is there by default, I can add it if
I want it; but I just don't understand why "a matrix [as a value] is
immutable" means that []= shouldn't be there regarding the data
structure.
Regards,
Jordan