Next up for patterns: type patterns in switch

John Rose john.r.rose at
Thu Jul 23 20:55:35 UTC 2020

Just one comment here:  This is a masterful summary of many months
work pursuing hard-won insights; thank you; let’s do this.

— John

P.S. Well, not exactly.  You didn’t expect *no* comment from me? :-)

It is slightly premature to completely outlaw `x instanceof 42`,
because of nulls:  You can replace that with `x == 42` only if `x`
is `int`.  With strings, identity is also a problem; `x instanceof "foo"`
does not replace with an `==` expression.  In the end, if we outlaw
`x instanceof 42` the workaround might be `Objects.equals(x,42)`
but that incurs boxing overhead if `x` happens to be a primitive.
So, I think the fate of `EXPR instanceof CON_PAT` is up for grabs.
That said, I’m fine with leaving it out for starters; it can be added
after further thought—or not.

More information about the amber-spec-experts mailing list