Project

General

Profile

Actions

Feature #5922

closed

Migrate equal? to identical?

Added by trans (Thomas Sawyer) almost 13 years ago. Updated about 12 years ago.

Status:
Rejected
Target version:
[ruby-core:42210]

Description

From Ruby docs: "the equal? method should never be overridden by subclasses: it is used to determine object identity (that is, a.equal?(b) iff a is the same object as b)."

I think it would make more sense to name such a method #identical?, since that is what it is doing --comparing identity. Over a sufficient period of time the current use of #equal? can be deprecated and possibly made better use of with a different definition. I realize this is not a minor change. This transition would probably be much like the one from #id to #object_id.

The reason I propose this, and why it is an issue for myself, is in of the design of assertion frameworks. For example, #assert_equal is a comparison of #==, not #equal?. We run into this naming conundrum and end up having to use assertion names that don't correspond well to the names of the underlying comparison. So that's the practical reason. But formally speaking, I think #identical? also better b/c it is more precise.


Files

5922.pdf (73.3 KB) 5922.pdf Migrate equal? to identical? trans (Thomas Sawyer), 07/01/2012 08:48 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0