On 2006-07-30 12:45:50, Antoon Pardon wrote: >> [...] we'd have to use a common definition of "variable". This is a term >> so widely used that I'm not sure there is a useful single definition of >> it; do you know one? > > A name in a scope to which is attached some value/object. Now whether > this attachment is in the form of storage or binding is IMO not > that important.
IMO this is not a useful definition of "variable", as it also includes what some languages would call a "constant". This definition even includes preprocessor macros. Once you try to come up with a definition that does not include these, it probably gets trickier. >> In any case, the following doesn't seem to be implementation detail (and >> rather a part of the language), but it's not really understandable with a >> C++ concept of "variable": >> >>>>> a=3 >>>>> id(a) >> 3368152 >>>>> b=a >>>>> id(b) >> 3368152 >>>>> b=4 >>>>> id(b) >> 3368140 >> >> You don't expect the "identity" of the variable b to change with a simple >> assignment from a C/C++ point of view. > > That depends on what you call the identity. If I had to translate this > into C++ it would be something like: > > int *a, *b; > > a = MakeInt(3); > b = a; > b = MakeInt(4); Yup. But in C/C++ speak, it's more common to call a and b "pointers" rather than "variables". Of course they are also sometimes called "pointer variables", but not usually "variables". It's of course not technically wrong to call the variables, but it's probably rare. And for a reason. >> but that doesn't mean that you expect C++ language constructs to behave >> like that. > > If you have implemented it with that purpose, you do. I'm not sure an implementation of C++ that behaves like Python when handling ints is still C++. I'm not sure where you're trying to go. I think that most people (and even Bruno, who argued this issue most strongly) call Python variables "variables" every now and then, or maybe even usually. But it was helpful for me to see the difference between Python variables and, say, C variables. I think this has been a useful discussion in this respect. There is a difference, and it is important (IMO). Whether Python variables are in fact "variables" probably depends mostly on your definition of "variable", and that's IMO a tough one -- a definition of "variable" that includes all those language elements that various languages call "variables", and nothing else (that's the tough part). Whether that definition exists, and whether it includes Python "variables", remains to be seen :) Gerhard -- http://mail.python.org/mailman/listinfo/python-list