On Wednesday, May 7, 2014 5:16:16 AM UTC+5:30, Chris Angelico wrote: > On Wed, May 7, 2014 at 7:00 AM, Mark H Harris wrote:
> Is this code mutating or rebinding? > x = 1.1 > y = 2.2 > x = x + y Heh! Neat example! > What language did I write that in? Is there really a fundamental > difference between languages in which that is equally valid syntax and > does exactly the same thing? Apart from the fact that BASIC defaults > to single-precision float (in the absence of a hash suffix), Python > uses double-precision, and REXX uses decimal strings, this sequence > will work identically in all of them. Does BASIC have variables? > Presumably, since you can pass them by reference. Does REXX? You can't > pass by reference (all you can do is EXPOSE, which is more like > scoping rules, only it isn't); a C function can fiddle with any named > variable in its caller's scope, so a common way to "return" multiple > values is to pass the name of a stem (which isn't an array, and isn't > a dict/mapping, and isn't really an object at all) into which the > results will be placed. Python has objects and names, and changes > which object a name is bound to. > The mechanics differ, but fundamentally, x started out as 1.1 and > ended up as 3.3. That means x varied in value, and is thus a variable. > The differences are relatively insignificant. Wrong conclusion! These 3 lines look the same and amount to much the same in python and C. But as the example widens to something beyond 3 lines, the difference will become more and more significant OTOH... As for meaning of the word 'variable,' the way mathematicians use it seems to date to the 16th century: http://en.wikipedia.org/wiki/Variable_%28mathematics%29#Genesis_and_evolution_of_the_concept That is, its closer to the binding notion of python than the imperative notion of C like languages. However if we go further back, the book by Al-Khwarizmi is about al-Jabr ie the name of the guy who invented algebra is used for 'algorithm'!! I find this ironic, given this current discussion: - algorithm corresponds to the mutating notion - algebra corresponds to the non-mutating notion -- https://mail.python.org/mailman/listinfo/python-list