Andrew Koenig writes: > The reason for that, I think, is that there are really three kinds of > "equality" that make sense, and only two of them are reasonably available: > > Value equality (==, which might be user-defined, because > the concept of "value" can be user-defined); > > Object identity ("is") > > Object equivalence (no easy way of expressing it today) > > By "object equivalence", I mean mutual substitutability--which is the same > as identity for mutable objects, but not for immutable ones. You'll have to help me out here... I just don't get it. Starting from your definition of object equivalence, let us divide all objects into two clases: mutable and immutable. Actually, instead I'm going to follow Martin v. Löwis' example[1] and divide all objects into identitiy objects, mutable values, and immutable values. Considering the meaningful concepts for each category: Identity Objects can be (meaningfully) compared by: * Object Identity To see if these are "the same object". Also useful for low-level memory stuff according to Tim. (just use '==', although 'is' would work too) Mutable Values can be (meaningfully) compared by: * Value Equality To see if these represent the same value. (just use '==') * Object Identity Whether two references will STAY equal if one is changed. Same as "mutual substitutibility" or "object equivalence". According to Tim, this is also handy for low-level memory stuff. (just use 'is') Immutable Values can be (meaningfully) compared by: * Value Equality To see if these represent the same value. Same as "mutual substitutibility" or "object equivalence". (just use '==') * Object Identity Whether two objects are actually using the same memory location. Useful ONLY for low-level memory stuff a la Tim. (just use 'is') Seems to me as if there are no more than TWO meanings for any given type of object, and that we provide two comparison operators in each case. So what's missing? -- Michael Chermside [1] http://mail.python.org/pipermail/python-dev/2004-February/042579.html
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4