What other languages use the same data model as Python?
Chris Angelico
rosuav at gmail.com
Sat May 7 19:43:28 EDT 2011
On Sun, May 8, 2011 at 8:54 AM, Gregory Ewing
<greg.ewing at canterbury.ac.nz> wrote:
> Ben Finney wrote:
>
>> No, I think not. The term “variable” usually comes with a strong
>> expectation that every variable has exactly one name.
>
> I would say that many variables don't have names *at all*,
> unless you consider an expression such as a[i] to be
> a "name". And if you *do* consider that to be a name,
> then clearly one variable can have a great many names.
>
> What would *you* call a[i]?
a is a variable; i is a variable; a[i] is an expression. It's not a
single name, and if you had two variables i and j with the same value,
nobody would disagree that a[i] and a[j] ought to be the same thing.
That's the whole point of arrays/lists/etc/etc. But if you want to fry
your noggin, wrap your head around REXX's compound variables:
a=5
b=3
array.a.b="Hello" /* see, this is a two-dimensional array */
c=63/10
array.c="world!" /* see, we can have non-integers as array indices */
d=a+1
result = array.a.b", "array.d.b /* "Hello, world!" */
So what is a "name" in REXX? You have to evaluate the compound
variable as a set of tokens, then evaluate the whole thing again, and
is that the name? Because the resulting "name" might not be a valid
identifier...
Yep, it's good stuff.
Chris Angelico
More information about the Python-list
mailing list