Wanted to ask on a possibility of introducing fiel...
# language-proposals
v
Wanted to ask on a possibility of introducing fields in interfaces. The main reason against having non-abstract fields (aside the compatibility with java8) always was the inability to have initializators for interfaces. But with
lateinit
it is possible to introduce syntax
interface A {lateinit val x: Int = f()}
with semantics that
f()
is called only on the first get-access. Fields in interfaces exist in Scala and are very useful for local caching, so when your non-abstract interface method needs caching for speeding up, you may introduce a private field for that. PS I may misuse
lateinit
in this context, it just gave me the idea