Inline Interface proposal

Inline interfaces - are exist only at compile time. All inline interface functions are inline.

Inline interfaces are just guaranty existence of some functions set that will be dissolved by compiler.

As example, where they can be used.
I have some data class (packet) that format recognized by some network transmitter.

Other classes, if we want to sent them via transmitter, have to implement some interface, and pass to some converter to packet format function.

Interface here just a contract.
For better performance could be great completely replace call to interface function with there body, just like inline functions do.
att: @abreslav

How it differs from expect / actual ?

How it differs

completely.
expect / actual provide public run-time contract. Inline interfaces - compile-time only

Seems very similar to type classes. The inline part doesn’t seem to be very important here (also, I think it would make compilation slow, as we effectively loose modularity of compilation).

If you are talking about a class hierarchy that you do control, you can use it right now, just applying inline extensions to types or by introducing marker contexts for additional functionality. If you want to add some functionality to existing interface, than you would like either by KEEP-87 or by KEEP-176. They mostly cover the same functionality, but use different design approach (and require different changes in code design to work).

1 Like