I really only was talking about the case where the compiler knows that it's an @objc method (with the understanding that the information is lost as soon as you make an unattributed T -> U closure out of it).
Either syntax would make me happy. Félix > Le 28 déc. 2015 à 13:49:22, Joe Groff <[email protected]> a écrit : > >> >> On Dec 28, 2015, at 10:46 AM, Félix Cloutier <[email protected] >> <mailto:[email protected]>> wrote: >> >> Would it be possible to add properties to closures/method objects? >> >> Right now, it's possible to write: >> >>> @objc >>> class Foo : NSObject { >>> func doSomething(value: Int) -> Int { >>> return value + 1 >>> } >>> } >>> >>> let method = Foo.doSomething >> >> Maybe we could have Foo.doSomething.selector for @objc methods? > > Once you have a normal function value, it's not guaranteed you can recover > any identity from it, since an arbitrary T -> U doesn't necessarily > correspond to an @objc method. I'm proposing we do this by type context, > similar to how we form C function pointers and blocks. Just like you can do: > > let fptr: @convention(c) (Double) -> Double = sqrt > > to get the function pointer for `sqrt`, you could say: > > let sel: Selector = Foo.doSomething > > to get the selector for `doSomething`. > > -Joe
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
