Richard Blackwood <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: >>First, new disciplines often redefine words to mean something >>different than the disciplines they were derived from. Variable is a >>good example of that. In math, a variable is a placeholder in an (a >>system of) equation(s), and will have associated with it a (possibly >> empty) set of values that satisfy the equation(s). >> > Not merely a placeholder, right? A variable in math is a 'placeholder' > for a dynamic value, one which can or does change. If one can graph > the movement (change) of foo, foo is a variable within that scope. For > example: > > foo = 5 > foo = 6 > > I can graph foo's movement/change. It can thus be considered a > variable within mathematics. If I write:
No. When I'm wearing my mathematicians hat, variables don't change values. What you are describing is a function, "foo", describing a mapping from time to numbers. You can graph that function. When doing calculus, we talk about the "rate of change" of a variable with respect to a second variable (dfoo/dt), but that's just shorthand for talking about the system foo = f(t). In this case, foo is a variable that has a solution set with many possible values. If you add an equation specifying t (i.e., t = 0) to the system, you'll change the solution set for foo to a single value: {f(t)}. Now, when I'm wearing my programmers hat, variables can be bound to different values (or, in other languages, change values) as the program progresses. In this case, the variable *is* changing. > foo = 5 > > I can graph this but it will merely be a static point, a > constant. Constants are not variables because they do not change, they > do not "vary" in content. Actually, the graph of foo = 5 is a straight line, passing through the point 5 on the foo axis, and parallel to any other axis in the system. It's a very simple system, with one equation in one variable with one possible solution. Ask your friend if foo is a variable if you write: foo = sqrt(1) In this case, the solution set for foo is {1, -1}. In Python, foo has the value 1.0 (if you do "import sqrt from math"). While there are programming languages that support multiple return values for functions, I'm not aware of any that define sqrt so that it will return both 1 and -1 (and I *have* to wonder if that's worth a PEP). >>In math, if you say "foo = 5", foo is a variable, with a single value >>(5) that satisfies the equation. In Python, if you say "foo = 5", foo >>is a variable, that currently references the value 5. >> >> > He would argue strongly against your notion of variable. In the > statement "foo = 5", foo is constant. He would thus argue that foo is > a constant and not a variable (regardless of whether you change foo's > value in subsequent statements). He's wrong. Foo is a variable in the single-equation system "foo = 5". The solution set for it is {5}. If the two equations are "foo = 5" and "foo = 6", then foo is a variable in a two-equation system with a solution set of {} (the empty set). I'd recommend your friend pick up an algebra textbook. It's been so long since I did any that I can't recommend one, though. Never forget: Constants aren't, variables won't. <mike -- Mike Meyer <[EMAIL PROTECTED]> http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list