On 9/07/20 3:26 am, Brandt Bucher wrote:
match <s>:
     case <p0> | <p1>: ...
     case <p2> | <p3> if <g0>: ...
     case <p4> | <p5>: ...
```

It's safe to use the same decision tree for <p0> through <p3>, but it must be rebuilt for 
<p4> and <p5>, since <g0> could have done literally *anything*.

I think you're being overly cautious here. To my mind, the guards
should be regarded as part of the pattern matching process, and so
people shouldn't be writing code that depends on them having side
effects.

As a nice consequence of adopting that rule, we would be able
to say that these are equivalent:

    case C(a.b): ...

    case C(x) if x == a.b: ...

--
Greg
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/NRTKPMUUOVJIAO3CTPGXW4JAI3DU2ZOY/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to