Richard Blackwood wrote:
Bengt Richter wrote:

On Sat, 23 Apr 2005 22:45:14 -0400, Richard Blackwood <[EMAIL PROTECTED]> wrote:



Robert Kern wrote:



Richard Blackwood wrote:



To All:

  Folks, I need your help. I have a friend who claims that if I write:

foo = 5

then foo is NOT a variable, necessarily. If you guys can define for me what a variable is and what qualifications you have to back you, I can pass this along to, hopefully, convince him that foo is indeed a variable.

None of us can do that unless you tell us what he thinks the word "variable" means. The terminology is a bit fluid. I suspect that your friend applying a somewhat restricted notion of "variable" that coincides with the behavior of variables in some other language.



Indeed, this language is math. My friend says that foo is a constant and necessarily not a variable. If I had written foo = raw_input(), he would say that foo is a variable. Which is perfectly fine except that he insists that since programming came from math, the concept of variable is necessarily the identical. This can not be true. For example, I may define foo as being a dictionary, but I can not do this within math because there is no concept of dictionaries within mathematics; yet foo is a variable, a name bound to a value which can change.


Maybe he doesn't know that foo = 5 in Python is not an equation as in math,
but a Python source language statement to be translated to a step in some
processing sequence.


Tell him in Python foo is a member of one set and 5 is a member of another,
and foo = 5 expresses the step of putting them into correspondence
to define a mapping, not declaring them equal.


Could I honestly argue this to him? From what basis do I argue that it is not an equation?

It's his responsibility to show that it *is* an equation.

x = x + 1

Equation? I think not.

In any event, he would likely (passionately) disagree considering his notion that programming is an off-shoot of math and thus at the fundamental level has identical concepts and rules. Believe it or not, he used to be a programmer. Back in the day (while I was getting my PhD in philosophy), he was a employed programmer using Cobol, Fortran, and other languages like that.

Okay, I take back my comment that this is not his field. I instead put forth the contention that he is a stark raving nutter. My qualifications to back me are that I cut my USENET teeth at talk.origins. I know my stark raving nutters.


Did his seemingly peculiar definition of variable exist at that time?

Oh, I'm sure *some* programming textbook from that time has tried to use such a definition and maintained the assertion that "programming is an off-shoot of math and thus at the fundamental level has identical concepts and rules." Both are rather naive, though, and the rest of the field has grown out of it. Your friend hasn't, it seems. Leave him to it, I say.


If you insist on convincing him, however, you can point him to Raphael Finkel's _Advanced Programming Language Design_[1], page 5 which defines "variables" as "named memory locations." In this formal context, what we often informally call "variables" in Python aren't. This is why we sometimes use the term "names" instead. In C, when I declare a variable, I also specify a piece of memory to which that name refers. When I assign a value to that variable, the value goes into that memory location. When I assign a new value there, I overwrite the data in that memory location with the new value. It doesn't work like that in Python. The name just points to the new object. No memory gets overwritten. Your friends other assertions suggest that this is not what he is talking about, though.

As always in terminology issues, what is correct depends on the conversation one is having. If I'm talking about a piece of Python code a colleague and I say, "so I put the value in a temporary variable--" and he says "No, it's not a variable, it's a name!", he has just volunteered for a severe beating. If I'm talking about comparative language design like Finkel is, the distinction is quite useful and no beatings need occur.

None of this has anything to do with the terminology as it is used in mathematics.

[1] http://www.nondot.org/sabre/Mirrored/AdvProgLangDesign/

--
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to