How can i compare to none class var in swift?

how compare callback1 and callback2

Code Block
public typealias CP_OnPortOpenedEvent_SwiftCallback = (_ handle: Int, _ name: String) -> Void
public func Test() {
    var callback1: CP_OnPortOpenedEvent_SwiftCallback = { (handle, name) in 
        
    }
    var callback2 = callback1
    print(callback1 == callback2)
}


You try to compare 2 functions, which is not possible in Swift, intentionally.

Read what Chris Later said:
https://stackoverflow.com/questions/24111984/how-do-you-test-functions-and-closures-for-equality


Chris Lattner wrote on the developer forums:
This is a feature we intentionally do not want to support. There are a variety of things that will cause pointer equality of functions (in the swift type system sense, which includes several kinds of closures) to fail or change depending on optimization. If "===" were defined on functions, the compiler would not be allowed to merge identical method bodies, share thunks, and perform certain capture optimizations in closures. Further, equality of this sort would be extremely surprising in some generics contexts, where you can get reabstraction thunks that adjust the actual signature of a function to the one the function type expects.
https://devforums.apple.com/message/1035180#1035180


I wondered why you wanted to compare the 2 func ?
How can i compare to none class var in swift?
 
 
Q