<html><body><div dir="ltr"><span style="color:rgb(255,255,255)!important">On 20 Jun 2022 at 16:40:32, Hunor Szegi <<a href="mailto:hunor.szegi@gmail.com">hunor.szegi@gmail.com</a>> wrote:</span><br></div><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(155,155,155)!important;padding-left:1ex;color:rgb(155,155,155)!important" type="cite">
<div dir="ltr"><div class="gmail_default" style="font-size:small" dir="ltr">….</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.</div></div></blockquote><div class="gmail_quote"><br></div><div class="gmail_quote"><div dir="ltr"><font size="2">Even money interprets this as 'i and j are valid, in-scope variables from where the </font><code style="border:1px solid rgb(63,63,63);background-color:rgb(37,37,37)!important;padding:0px 2px;border-top-left-radius:2px;border-top-right-radius:2px;border-bottom-right-radius:2px;border-bottom-left-radius:2px">switch</code> is being defined, and this is attempting to match the case of a Box such that its deconstructed values are equal to i and j'. In other words, Moving to Point instead:</div><div dir="ltr"><br></div><div dir="ltr"> var x = 5;</div><div dir="ltr"> var y = 10;</div><div dir="ltr"> switch (point) {</div><div dir="ltr"> case Point(x, y) -> …</div><div dir="ltr"> }</div><div dir="ltr"><br></div><div dir="ltr">This could reasonably be interpreted as ‘match the case where x=5 and y = 10’, i.e. as if that said <code style="border:1px solid rgb(63,63,63);background-color:rgb(37,37,37)!important;padding:0px 2px;border-top-left-radius:2px;border-top-right-radius:2px;border-bottom-right-radius:2px;border-bottom-left-radius:2px">case Point(5, 10) -> ...</code></div><div><br></div><div><br></div><div dir="ltr">There’s some fairly severe limits on how far one should take ‘in a world where nobody knows how to read these things, let’s enumerate the many many ways folks might interpret some completely new language feature’, but java does have rather a large amount of existing coders, so introducing new features in a way that causes lots of confusion is best avoided, no doubt.</div><div dir="ltr"><br></div><div dir="ltr">At any rate, one extra reason as to why omitting the <code style="border:1px solid rgb(63,63,63);background-color:rgb(37,37,37)!important;padding:0px 2px;border-top-left-radius:2px;border-top-right-radius:2px;border-bottom-right-radius:2px;border-bottom-left-radius:2px">var</code> is stylistically problematic.</div><div dir="ltr"><br></div><div dir="ltr">I assume, given that the feature has been rolled out and is seeing active additions, debates on syntax are valid :)</div><div dir="ltr"><br></div><div dir="ltr"><div dir="ltr"> --Reinier Zwitserloot<br></div><div dir="ltr"><br></div><div class="gmail_quote"></div></div></div>
</div></body></html>