[OT] Perl woes

Andy Armstrong andy at hexten.net
Thu Jan 29 12:31:37 GMT 2009


On 29 Jan 2009, at 12:15, James Laver wrote:
>>> As a result, classes like NSString override == and 'isEqual' to
>>> actually do things like string comparisons. So you can use == on
>>> string objects just fine :-)
>
> This is where the overloading happens, and in a lot of other languages
> as well (smalltalk for one, although that doesn't have pointers in the
> c style).


But ObjC doesn't have operator overloading does it?

From:
   http://borkwarellc.wordpress.com/2007/08/19/ \
     objective-c-is-stupid-but-i-still-like-it/
or:
   http://lyxus.net/mel
> So, when you’re dealing with Objective-C, and things don’t behave  
> the way you think they should, consider what’s going on under the  
> hood:
>
> NSString *thing1 = ...; NSString *thing2 = ...; if (thing1 ==  
> thing2) {
> This is just pure C right here (no @’s or []’s are involved, so the  
> Objective-C part of the world doesn’t kick in. No ()’s involved, so  
> no function calls are happening. Therefore, only a small number of  
> bytes are involved. Each string could be megabytes long, but the  
> comparison will just be four bytes (eight bytes on a 64-bit system).  
> So this is just testing whether one address is equal to another  
> address. An “identity test”, vs a test for equivalency, which is  
> what the programmer probably wanted in the first place. Assuming  
> that the two strings are not pointing to the same @"literal  
> NSString", these will have different addresses, and the comparison  
> will be a false one. (it’s not my nose, it’s a false one)
>

-- 
Andy Armstrong, Hexten






More information about the london.pm mailing list