I am just reading Kotlin Language Guide and I have some feedback as well as questions.
I like the guide. It is precise and concise. But still has some errors(?) and leaves some questions unanswered.
I have my questions after reading page “Interfaces”:
- I think a snippet of code in topic “Interfaces Inheritance” has an error: class Employee does not declare any implemented interfaces.Does Kotlin support implicit interfaces as in Go? If this is the case then it should be written in that page. Otherwise the error should be fixed because it confuses readers.
- Is it possible to declare protected members of the interface? This aspect is not covered. I know how it is in Java but other readers may have another background and it may be not so obvious. At the same time Kotlin compiler may behave differently from Java.
- I assume that all methods in interfaces are open by default unless they are declared final (BTW, is it possible?). It is not covered, so I can only guess or check it with the compiler.
- I still don’t get how static members of classes (as well as interfaces) are handled in Kotlin. Yes, I have seen “Companion objects” but, first, this is not the same as static member of Java class, and secondary, I am not sure that they are allowed in interfaces.
Theoretically it is possible to have “static virtual” members of classes (not in Java). For example, it is possible in Delphi. Basically static virtual methods are just methods of class itself rather than an instance of the class and they are listed in class VMT as other virtual methods. Static virtual property could be implemented as static virtual get/set class methods that may be backed by a static field. If you have a reference to a class than you can call this class method or access class field which can be virtual.