On Jan 10, 2020, at 1:18 PM, Guy Steele <[email protected]> wrote: > Well, if the _only_reason to allow instanceof with a constant is floats and > doubles (comparing to NaN is the one thing that == or .equals might not > handle properly), then it’s not a very good reason; I dare say Float.isNan(x) > is the first thing that would jump to mind, and it would be a whole lot more > readable as well.
The refactoring story is another reason: Allowing instanceof simplifies refactoring, and also any spec that appeals to desugaring. A complicated pattern might contain a constant K somewhere. It’s surely better to desugar uniformly to instanceof applications, and *then* note that in some cases x instanceof K can be further desugared to (Float.isNan(K) ? Float.isNan(x) : x == K), when x is a float.
