On 04/12/2019 00:17, fo...@univ-mlv.fr wrote:
I don't follow you, conceptually a pattern matching is an optional of tuples (i don't want to go more deep than that given that the real implementation is still in flux), you can construct an optional if getReturnComponents() returns null or not.

Right - but what happens when you do:

Class<?> x = ...
if (x instanceof Class.recordComponents(var components)) {
   ...
}

If the method Class::getRecordComponents always returns something (e.g. an empty array) and we claim that a deconstructor here is the dual case of that, that might suggest that the pattern above always matches (in some cases with 'components' bound to an empty array). My guts is that people writing the above code will want it NOT to match if 'x' is not a record class; but if you go there, then you have what seems like an asymmetry: I can ask String.class.getRecordComponents (and get an empty array) but I can pattern-match String.class, because the extractor also does the 'isRecord' trick, and fail to match if that returns false.

Not saying it's not doable... but feels more awkward for some reason.

Maurizio

Reply via email to