On 2005-07-22 18:03:38 +0100 Markus Hitter <[EMAIL PROTECTED]> wrote:

Regarding to this, in my little recherche yesterday, I couldn't find any difference between -isEqual:, -isEqualTo: and -isEqualToDate:. The last type is supported by some common other classes as well, e.g. -isEqualToString:, -isEqualToNumber:, ...

My impression was, -isEqual: is meant for coarse comparisons or hash comparisons. But that's an impression only.

I don't know of any -isEqualTo: method. AFAIK there is only -isEqual: or the variants with the class in the name (-isEqualToString:, -isEqualToNumber: etc)

Since it's interesting for coding in GNUstep/Cocoa as well: Does anybody know what's the difference between the members of these trios? Why does -isEqualTo: exist at all

I don't believe it does.  At least, not in GNUstep.

and why doesn't NSDate simply override -isEqual: instead of introducing -isEqualToDate:?

It does override -isEqual:

My understanding is that the variants with the class name in them are intended as optimisations ... where the method may assume that what it gets as an argument is a member of the correct class, thus avoiding to need to check what class the argument belongs to.

Thus, for NSDate, -isEqual: might be implemented as -

- (BOOL) isEqual: (id)anObject
{
  if ([anObject isKindOfClass: [NSDate class]])
    {
      return [self isEqualToDate: (NSDate*)anObject];
    }
  return NO;
}

Is it just an historical artefact? Should I file a bug report at Apple to get rid of at least -isEqualTo:?

Maybe ... I don't know about it.



_______________________________________________
Gnustep-dev mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnustep-dev

Reply via email to