[Python-Dev] redefining is (original) (raw)
Robert Brewer fumanchu at amor.org
Fri Mar 19 12:55:42 EST 2004
- Previous message: [Python-Dev] (old) module names
- Next message: [Python-Dev] redefining is
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Andrew Koenig wrote:
8 The original author of the proposal on comp.lang.python was clearly disturbed at getting object identity when equivalence would have made more sense, and was proposing to change things as follows:
x == y Value equality x is y Object equivalence id(x) == id(y) Object identity I can completely understand why this change might be considered too large to make to an existing language-- just like changing the wan C++ handles virtual destructors would be--but nevertheless I think it's interesting to consider the abstract merits of an idea such as this one, perhaps for the mythical Python 3.0. To put it another way: If the three operations above existed, I am finding it hard to think of many cases in which the third of these operations would be more useful than the second, which suggests that the second should be easier to express.
Wonderfully well-stated, Andrew; thanks for taking the time. You've moved this topic out of the realm of "crackpot ideas" for me. ;)
Given the above, it seems reasonable to me that, rather than change the behavior of "is", one should introduce a new operator (or function, etc.). That is, instead of the above, I would expect:
Value equality: x == y
Object identity: x is y
or: id(x) == id(y)
Object equivalence: x equiv y
or: equiv(x, y)
The reasons being:
Backward compatibility, par for the course.
"A is B" in English is quite specifically about identity, not equivalence. Can you think of a case where this is not so? If you can, then I'd bet it's because "mutual substitutability" is always true for identical objects--the equivalence is a side-effect of being identical. Note that I'm not talking about "A is a B" or other statements. I also assume, for Python, that if id(x) == id(y), then (x equiv y) would also be True.
Now if we can only find a short English word that means "mutually substitutable". ;)
Robert Brewer MIS Amor Ministries fumanchu at amor.org
- Previous message: [Python-Dev] (old) module names
- Next message: [Python-Dev] redefining is
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]