<div dir="ltr"><div class="gmail_default" style="font-size:small">Hi All,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I'm looking at the record pattern (JEP 405):</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">"A record pattern consists of a type, a (possibly empty) record component pattern list which is used to match against the corresponding record components, and an optional identifier."<br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">(I guess the pattern should be matching to the original list of record components, and it isn't related to the constructors. (Or is it possible that the non-canonical constructors could be used here?) I presume not, as then a pattern check could have side effects as well.)<br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">So let's see an example record:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">record Box(Object content, int size) {}</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">The following pattern case label won't work: "case Box(i, j) ->" , as "i" and "j" are not patterns. I see the point to describe the structure as simply as possible. And given that a single variable can't be a pattern, it's difficult to cover both the "Box(i, j)" and a compound "Box(String i, int j)" pattern. But from the user perspective it would be the most straightforward.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">If the type of the components are given (no "overloaded" constructor could play a role), why is it necessary to provide the type in the pattern? Of course the possibility of providing a subtype of the component is beneficial, but that can be treated as a compound pattern - a record pattern, which optionally can contain type patterns.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I saw this example: "Point(var x, var y) - so this is a special case of the type pattern, where the component type is inferred. But why is the "var" necessary here? Isn't it a counterexample, which breaks the specification, as "var x" isn't a pattern. Indeed it is very similar to a type pattern, but not exactly that. (You can't write "case var i ->".)</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I can imagine a modified specification, instead of a list of patterns, using a list of "pattern variable or pattern".</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Maybe I misunderstood something, as of course I wasn't able to try it. In this case sorry in advance.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Finally some questions:<br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">case Box(Box(String x, int y) a, int z) b -></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I haven't seen a similar example in the JEP, but based on the description, both the "a" and "b" pattern variables should be allowed, isn't it? (It would be good.)<br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">And can we use a constant as pattern, or the null pattern? For example:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">case Box(Box(null, int y) a, 3) b -><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Thank you in advance,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Regards,</div><div class="gmail_default" style="font-size:small">Hunor</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><span style="color:rgb(0,0,0);font-family:"DejaVu Sans","Bitstream Vera Sans","Luxi Sans",Verdana,Arial,Helvetica;font-size:13.3333px"><br></span></div><div class="gmail_default" style="font-size:small"><br></div></div>