Re:Weird Python Integers
by hyperpape on Thursday August 24, 2017 @09:03PM
(#15095376)
What's the meaning of
I know why the implementation lets me ask that question and I know why it's false, but I'd say that there's no reasonable question I'd ever want to ask using that expression.
[ Parent
| on HN ]
Re:Weird Python Integers
by chrisseaton on Friday August 25, 2017 @05:18AM
(#15097160)
You can think up an unreasonable example for anything though.
If I have a graph data structure then `node == node` with identity does make sense to me in lots of cases.
And what's the value equality of `(new Object()).equals(new Object())` - they have no value.
The point is that the language treats numbers as objects when they aren't.
It's not that reference semantics don't have a place, it's just that the place isn't numbers.
As for your second question, it looks like the type system has two embarrassing questions: what the heck does "new Object()" mean? Nothing worth saying.
Re:Weird Python Integers
by chrisseaton on Saturday August 26, 2017 @03:27PM
(#15106935)
I use `new Object()` in my code and I use it exactly for identity equality! If I want a unique ID for something I create a new object and it's guaranteed it will never be reference equality to any other object anyone else could construct.