<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div>I do not know all the answers :)</div><div><br data-mce-bogus="1"></div><div>i would like to emphasis that OR (and AND) are not a binary OR but a n-arity OR,</div><div>i think it's important because it's easier to re-organize/reason about the pattern if you are not limited by the pattern being binary were decision are more local.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>You can find the AND pattern when you deconstruct an object that have several fieds,<br data-mce-bogus="1"></div><div>by example for</div><div>  case BinOp(Value v1, Value v2) -> accept(v1, v2)<br data-mce-bogus="1"></div><div>you can decompose it too<br data-mce-bogus="1"></div><div>  x match BinOp -> let (v1, v2) = x.deconstruct()] AND(v1 match Value, v2 match Value) -> accept(v1, v2)<br data-mce-bogus="1"></div><div><br></div><div>Rémi<br data-mce-bogus="1"></div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>De: </b>"Brian Goetz" <brian.goetz@oracle.com><br><b>À: </b>"amber-spec-experts" <amber-spec-experts@openjdk.java.net><br><b>Envoyé: </b>Samedi 4 Novembre 2017 23:20:44<br><b>Objet: </b>[patterns] AND patterns, OR patterns, fall though <br></blockquote></div><div data-marker="__QUOTED_TEXT__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><span data-mce-style="font-family: Menlo;" style="font-family: Menlo;" face="Menlo">In theory, patterns can be combined with AND and OR to produce new patterns, if their target types and binding lists are compatible.  Note also that most fallthroughs (those where the case labels immediately follow other case labels, with no intervening statements) can be expressed as OR patterns.  </span></span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><span data-mce-style="font-family: Menlo;" style="font-family: Menlo;" face="Menlo"><br class=""></span></span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><span data-mce-style="font-family: Menlo;" style="font-family: Menlo;" face="Menlo">Some form of OR patterns are almost a forced move if we want to have expression switches with patterns:</span></span></div><span data-mce-style="font-family: Menlo;" style="font-family: Menlo;" face="Menlo"><tt style="background-color: rgb(255, 255, 255);" class=""><br class="">    int numLetters = switch(s) {<br class="">        case "one", "two" -> 3;<br class="">        case "three" -> 5;<br class="">        ...<br class="">    }<br class=""><br class="">Because, while statement switches can simply repeat the labels:<br class=""><br class="">    case "one":<br class="">    case "two":<br class=""><br class="">this idiom looks pretty stupid if we try to transplant it to expression switches:<br class=""><br class="">    case "one" -><br class="">    case "two" -> wtf?<br class=""><br class="">OR patterns give us much of what fallthrough gives us; the only difference is the ability to have intervening statements between the case labels.  Given that expression switches push us towards OR patterns, why not double down, using this for statement switches, and prohibit fallthrough for statement switches too?  This is simpler and covers what seem like the important cases.  </tt></span><div class=""><div class=""><span data-mce-style="font-family: Menlo;" style="font-family: Menlo;" face="Menlo"><tt style="background-color: rgb(255, 255, 255);" class=""><br class=""></tt></span></div><div class=""><tt style="background-color: rgb(255, 255, 255);" class=""><span data-mce-style="font-family: Menlo;" style="font-family: Menlo;" face="Menlo">In theory, an OR pattern of P and Q would require that both P and Q are applicable to the static type of the target, and (in the most strict interpretation) have identical binding variable lists. </span></tt></div><div class=""><tt style="background-color: rgb(255, 255, 255);" class=""><span data-mce-style="font-family: Menlo;" style="font-family: Menlo;" face="Menlo"><br class=""></span></tt></div><div class=""><span style="background-color: rgb(255, 255, 255); font-family: Menlo;" class="">Note that we have a form of OR patterns now, with multi-catch:</span></div><div class=""><br style="font-family: monospace; background-color: rgb(255, 255, 255);" class=""><span data-mce-style="background-color: #ffffff; font-family: Menlo;" style="background-color: #ffffff; font-family: Menlo;" face="Menlo">    catch (E1 | E2 identifier)</span><br style="font-family: monospace; background-color: rgb(255, 255, 255);" class=""><br style="font-family: monospace; background-color: rgb(255, 255, 255);" class=""><span data-mce-style="background-color: #ffffff; font-family: Menlo;" style="background-color: #ffffff; font-family: Menlo;" face="Menlo">Though, this might not really be what we want an OR pattern to look like, as this looks like the OR of "E1" (no bindings) and "E2" (with bindings), which would fail our restriction on the binding variable lists being the same.  An OR pattern would more correctly be written (E1 e | E2 e).  (However, we could interpret “E1|E2 identifier” as a union type-test pattern if we wanted to unify catch with patterns.)</span></div><div class=""><span data-mce-style="font-family: Menlo;" style="font-family: Menlo;" face="Menlo"><tt style="background-color: rgb(255, 255, 255);" class=""><br class=""></tt></span></div><div class=""><span data-mce-style="background-color: #ffffff; font-family: Menlo;" style="background-color: #ffffff; font-family: Menlo;" face="Menlo">The big question is whether we need OR patterns at all, or whether this is merely an artifact of the switch statement.  For the matches expression, we can express ORs clearly enough without it:</span><br style="font-family: monospace; background-color: rgb(255, 255, 255);" class=""><br style="font-family: monospace; background-color: rgb(255, 255, 255);" class=""><span data-mce-style="background-color: #ffffff; font-family: Menlo;" style="background-color: #ffffff; font-family: Menlo;" face="Menlo">    if (x matches P || x matches Q)</span><br style="font-family: monospace; background-color: rgb(255, 255, 255);" class=""><br style="font-family: monospace; background-color: rgb(255, 255, 255);" class=""><span data-mce-style="background-color: #ffffff; font-family: Menlo;" style="background-color: #ffffff; font-family: Menlo;" face="Menlo">(and we need to support this anyway.)  If we used comma to separate patterns:</span><br style="font-family: monospace; background-color: rgb(255, 255, 255);" class=""><br style="font-family: monospace; background-color: rgb(255, 255, 255);" class=""><span data-mce-style="background-color: #ffffff; font-family: Menlo;" style="background-color: #ffffff; font-family: Menlo;" face="Menlo">    case 1, 2, 3: </span><br style="font-family: monospace; background-color: rgb(255, 255, 255);" class=""><span data-mce-style="background-color: #ffffff; font-family: Menlo;" style="background-color: #ffffff; font-family: Menlo;" face="Menlo">    case Foo x, Bar x, Baz x:</span><br style="font-family: monospace; background-color: rgb(255, 255, 255);" class=""><span data-mce-style="background-color: #ffffff; font-family: Menlo;" style="background-color: #ffffff; font-family: Menlo;" face="Menlo">    case Foo(var x), Bar(var x), Baz(var x): </span><br style="font-family: monospace; background-color: rgb(255, 255, 255);" class=""><br style="font-family: monospace; background-color: rgb(255, 255, 255);" class=""><span data-mce-style="background-color: #ffffff; font-family: Menlo;" style="background-color: #ffffff; font-family: Menlo;" face="Menlo">Is that clear enough?  Is that unambiguous enough?  If this works, this is nice because it works cleanly with existing constant switches too.  I think this is pretty good.  </span><br style="font-family: monospace; background-color: rgb(255, 255, 255);" class=""><span style="font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><br class=""></span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><span data-mce-style="font-family: Menlo;" style="font-family: Menlo;" face="Menlo">So, concrete proposal:</span></span></div><div class=""><span data-mce-style="font-family: Menlo;" style="font-family: Menlo;" face="Menlo"><tt style="background-color: rgb(255, 255, 255);" class=""><b class=""> - Allow multiple patterns to be separated by commas in a case label;</b></tt></span></div><div class=""><tt style="background-color: rgb(255, 255, 255);" class=""><b class=""><span data-mce-style="font-family: Menlo;" style="font-family: Menlo;" face="Menlo"> - Treat </span>“<span data-mce-style="font-family: Menlo;" style="font-family: Menlo;" face="Menlo">case X: case Y:” as sugar for “case  X, Y:” in statement switches;</span></b></tt></div><div class=""><tt style="background-color: rgb(255, 255, 255);" class=""><span data-mce-style="font-family: Menlo;" style="font-family: Menlo;" face="Menlo"><b class=""> - Impose the “same bindings” rule when multiple patterns are combined in this way;</b></span></tt></div><div class=""><tt style="background-color: rgb(255, 255, 255);" class=""><span data-mce-style="font-family: Menlo;" style="font-family: Menlo;" face="Menlo"><b class=""> - Disallow fall through into patterns with binding variables. </b></span></tt></div><div class=""><tt style="background-color: rgb(255, 255, 255);" class=""><span data-mce-style="font-family: Menlo;" style="font-family: Menlo;" face="Menlo"><br class=""></span></tt></div><div class=""><tt style="background-color: rgb(255, 255, 255);" class=""><span data-mce-style="font-family: Menlo;" style="font-family: Menlo;" face="Menlo">Note that we don’t have to create a new kind of switch here to prohibit fall through; we just don’t allow fall through into non-constant pattern cases.  <br class=""></span></tt></div></div><div class=""><tt style="background-color: rgb(255, 255, 255);" class=""><span data-mce-style="font-family: Menlo;" style="font-family: Menlo;" face="Menlo"><br class=""></span></tt></div><div class=""><div class=""><tt style="background-color: rgb(255, 255, 255);" class=""><span data-mce-style="font-family: Menlo;" style="font-family: Menlo;" face="Menlo">Note that Scala lets you OR multiple patterns together:</span><br class=""></tt><br style="background-color: rgb(255, 255, 255);" class=""><pre class="prettyprinted lang-scala prettyprint" style="margin-top: 0px; padding: 5px; border: 0px; font-variant-ligatures: normal; font-variant-numeric: inherit; font-stretch: inherit; font-size: 13px; line-height: inherit; vertical-align: baseline; width: auto; max-height: 600px; overflow: auto; background-color: rgb(239, 240, 241); color: rgb(57, 51, 24); word-wrap: normal; orphans: 2; widows: 2;"><code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; white-space: inherit;" class=""><span data-mce-style="font-family: Menlo;" style="font-family: Menlo;" face="Menlo"><span class="kwd" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(16, 16, 148);">def</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);"> matcher</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">(</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">l</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">:</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);"> </span><span class="typ" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(43, 145, 175);">Foo</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">):</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);"> </span><span class="typ" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(43, 145, 175);">String</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);"> </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">=</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);"> </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">{</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">
  l </span><span class="kwd" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(16, 16, 148);">match</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);"> </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">{</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">
    </span><span class="kwd" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(16, 16, 148);">case</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);"> A</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">()</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);"> </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">=></span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);"> </span><span class="str" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(125, 39, 39);">"A"</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">
    </span><span class="kwd" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(16, 16, 148);">case</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);"> B</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">(</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">_</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">)</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);"> </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">|</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);"> C</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">(</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">_</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">)</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);"> </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">=></span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);"> </span><span class="str" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(125, 39, 39);">"B"</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">
    </span><span class="kwd" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(16, 16, 148);">case</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);"> _ </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">=></span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);"> </span><span class="str" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(125, 39, 39);">"default"</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">
  </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">}</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">
</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant-ligatures: inherit; font-variant-position: inherit; font-variant-caps: inherit; font-variant-numeric: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">}</span></span></code></pre><span data-mce-style="font-family: Menlo;" style="font-family: Menlo;" face="Menlo"><tt style="background-color: rgb(255, 255, 255);" class="">but I'm not sure whether this is really an OR on patterns, or whether this is a "feature" of match?  But, this seems a pretty questionable syntax choice, as:<br class=""><br class=""></tt><span style="background-color: rgb(255, 255, 255);" class=""></span></span><blockquote style="background-color: rgb(255, 255, 255);" class=""><span data-mce-style="font-family: Menlo;" style="font-family: Menlo;" face="Menlo"><tt class="">scala> 1 match {</tt><br class=""><tt class="">     | case 1 | 2 => "one";</tt><br class=""><tt class="">     | }</tt><br class=""><tt class="">res0: String = one</tt><br class=""><br class=""><tt class="">scala> 1 | 2</tt><br class=""><tt class="">res1: Int = 3</tt><br class=""></span></blockquote><tt style="background-color: rgb(255, 255, 255);" class=""><span data-mce-style="font-family: Menlo;" style="font-family: Menlo;" face="Menlo">So, even though 1|2 is an integer constant whose value is 3, "case 1|2" is an OR pattern.  <br class=""><br class=""><br class="">Similarly, its even less clear that we need AND patterns.  Though I could imagine wanting intersection type-test patterns, like:<br class=""><br class="">    switch (lambda) {<br class="">        case Predicate p && Serializable: ...<br class="">        case Predicate p: ...<br class="">    }<br class=""><br class="">Are there compelling use cases for AND patterns that I’m missing?  <br class=""><br class=""></span><br class=""></tt></div></div><br></blockquote></div></div></body></html>