Instance pattern vs functional interface
Remi Forax
forax at univ-mlv.fr
Tue Jan 26 12:06:09 UTC 2021
As usual, when introducing a new feature, the complexity arise with the interactions with the other already existing features.
We have instance patterns, we have functional interface,
does those things can be mixed ?
Is an interface with one abstract pattern a functional interface ?
interface Matcher {
pattern [String] is(String s);
}
Can i declare a lambda with bindings ?
Matcher upperCase = [String] (String s) -> ...
as an equivalent of
Matcher upperCase = new Matcher() {
pattern [String] match(String s) {
...
}
};
So i can pattern match on it ?
Object o = ...
if (o instanceof upperCase.is(String value)) { ... }
regards,
Rémi
More information about the amber-spec-experts
mailing list