Contents (package MULK.OBJECTIVE-CL)

Standard Generic Function OBJC-EQUAL


Test whether two objects are equal.


objc-equal x y

Arguments and Values:

x --- an object.

y --- an object.

Returns: equal-p --- a generalized boolean.


If at least one of the objects x and y is not an Objective-C instance wrapper, objc-equal behaves the same as equal.

For Objective-C instance wrappers, objc-equal behaves the same as (or (objc-eql x y) (invoke x :is-equal y) (invoke y :is-equal x)), except that it converts the return values of the invocations into generalized booleans before evaluating said expression. (Please note that, as there is no way to distinguish methods that return booleans from those that return numbers in the Objective-C runtime, the invocations will return numbers.)


(objc-equal (find-objc-class 'ns-string)  
            (find-objc-class 'ns-string))  
 ;=> T  
(objc-equal (find-objc-class 'ns-string)  
            (find-objc-class 'ns-object))  
 ;=> NIL  
(setq greeting1 (invoke (find-objc-class 'ns-string)  
                        :string-with-u-t-f-8-string "Mulk."))  
 ;=> #<GSCBufferString `Mulk.' {8109A38}>  
(setq greeting2 (invoke (find-objc-class 'ns-string)  
                        :string-with-u-t-f-8-string "Mulk."))  
 ;=> #<GSCBufferString `Mulk.' {8109DB0}>  
(objc-equal greeting1 greeting2)  
 ;=> T  
(objc-eql greeting1 greeting2)  
 ;=> NIL  
(objc-equal greeting1 greeting1)  
 ;=> T  
(objc-eql greeting1 greeting1)  
 ;=> T  

See Also:

objc-eql, invoke