case null / null pattern (v2)

Remi Forax forax at univ-mlv.fr
Mon Apr 18 22:49:58 UTC 2022


I've found a way to encode the null pattern if you have a record

record Foo(int x) { }

Foo foo = ...
return switch(foo) {
  case Foo(int _) foo -> "i'm a foo not null here !";
  case Foo fooButNull -> "i can be only null here !"; 
};

I wonder if allowing those two patterns, a record pattern and a type pattern using the same type is a good idea or not, it seems a great way to obfuscate thing.

Rémi


More information about the amber-spec-experts mailing list