gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: isEqual: and hash in NSDate


From: Richard Frith-Macdonald
Subject: Re: isEqual: and hash in NSDate
Date: Fri, 22 Jul 2005 19:35:04 +0100

On 2005-07-22 18:03:38 +0100 Markus Hitter <address@hidden> 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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]