Qualified appology (was Re: anything like C++ references?)
owski at hotmail.com
Mon Jul 14 20:44:02 CEST 2003
Stephen Horne <intentionally at blank.co.uk> wrote in message news:<1br3hv4434gn7p2pdg1bgtg8dtlak3id3s at 4ax.com>...
> I've said my piece on meanings derived from computer science (and in
> turn from mathematics, as it happens - variables as placeholders for
> values predate electronic computers by quite some time.
The mathematics I'm used to has a very different concept of assignment
than does a static language like C. Here's why.
In math there are global unchanging objects called numbers, 1, 2, 3,
etc. If I have 2 variables, x and y and they both equal 500, then
they both are names bound to the value 500. They are not each copies
of the value 500, math has no such concept, there is only one 500.
C, and most static languages, have the concept of memory location,
which doesn't exist in math. In C a variable is bound to a memory
location which contains a value, not like math where the variable
itself contains the value. Therefore I can have two variables, x and
y, that point to their own distinct copy of 500 and when I assign a
value, it copies the 500 into the memory location bound to x.
Now, what if I have x and y bound the the same memory location? If I
change X I also change Y. That's not how mathematics works. If X and
Y are to have to same value, they do so because of some relation to
their meaning, and they are both bound to 500, not simply because I
changed the value of X. This is a concept that simply doesn't exist
Python is more like the math form. There is only one instance of the
number 500 and a name (variable) is bound to it or it isn't. To
change the value of 500, then I must rebind the name, exactly in
mathematics. However, Python differs from math in that math doesn't
have mutable values (well it may when you get into real complex
calculus, I don't know, never been there).
More information about the Python-list