Hacker News new | past | comments | ask | show | jobs | submit login

I think the issue only exists for "value" types anyway. Reference equality works perfectly well for all types where I've used inheritance.



Reference equality's inability to survive a persistence round trip is the big killer. And sneaking in a round trip in a process that used to be fully in memory is where dragons lurk.


Equality is the least of your problems if you multiple instances of the same entity floating around.


Sometimes you are seeing if a constructed instance equals an existing one. I would presume that is rather common. Especially with points, a basic collision system is often basically an equality check. Right?


A "point" would be a value type and you wouldn't use reference equality or inheritance for a value type.

But if this were a game you might have a "BigBoss" instance than inherits from "Enemy". If you had one boss, you'd only have one instance of it, and you would use reference equality. If you round-tripped and ended up with 2 instances of the same boss then you're already in trouble.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: