Hello! Quick question: protocols are imported in K...
# kotlin-native
d
Hello! Quick question: protocols are imported in Kotlin as interfaces with Protocol name suffix, i.e.
@protocol Foo -> interface FooProtocol
. Why? I guess this is a question for the designers of Kotlin/Native but I’m just wondering what is the reason behind that. My opinion is that this is unnecessary and I would prefer this to be transparent and just use the interface with the original protocol name. I do not see why we should be aware about the fact that it comes from a framework.
s
Hello! Because Objective-C allows declaring class and protocol with the same name. See e.g.
NSObject
class and
NSObject
protocol. So we can’t import both to Kotlin using original names. Current approach is a bit conservative and may be improved later.
👍 1
d
Oh I see, it makes sense. Thanks for your answer Svyatoslav 🙂
I asked that because I was creating
typealias
for those cases to make the names ‘less verbose’