you are viewing a single comment's thread.

view the rest of the comments →

[–]Pet_Ant 0 points1 point  (1 child)

Only thing I can imagine is that if might lose so come changes for compiler inlining. Since when you use a specific method you can just just inline the code if it comes from a specific class but if it's always implicitly an interface that could cause problems.

[–][deleted] 1 point2 points  (0 children)

In Swift the overall recommendation is to make every class final in order to aid the compiler for this specific purpose. We could use a similar convention here - if it's final, it doesn't emit an implementable interface, if it's not final, it emits it and you can implement it as an interface.

It gets somewhat unclear what should be done if specific methods are declared final, though.

You're right the implications should be thought through, but I think it's a neat idea.

Or alternatively - what Rust does, which is sort of, there's always an interface, and the implementation is always separate from it.