4 ms·
Java type system is not fully nominal anymore, the operator :: does structural typing. interface I { void m(); } class A { void hello() { ... } } I i = n
by _old_dude_ 7y ago
Java type system is not fully nominal anymore,
the operator :: does structural typing.
interface I { void m(); }
class A { void hello() { ... } }
I i = new A()::hello;
- jolux 7y agoIsn't this just the stuff making all lambdas implicitly implement a single-method interface and such?
- int_19h 7y agoOn JVM level, yes. But on Java level, the type of the method is structurally matched to the type of the interface.
- jolux 7y agoThe name of the function is typically the same though, even with structural typing. This doesn’t seem quite like that.
- int_19h 7y agoIf you mean the name of the function in the interface, it's basically ignored in this pattern, similar to how argument names are ignored. The entire interface definition should be treated as a function type with some redundant metadata.
- _old_dude_ 7y agoyes, a lambda is (mostly) desugared as a static method and then the operator :: is applied.