On Wed, Oct 28, 2020 at 12:48 PM Emily Bowman <silverback...@gmail.com>
wrote:

> On Wed, Oct 28, 2020 at 6:49 AM Jean Abou Samra <j...@abou-samra.fr>
> wrote:
>
>> where `impossible` raises AssertionError.
>>
>
> Reserving a common English word as a new keyword (whether fail or
> impossible) is the mother of all breaking changes. The syntactic sugar it
> provides is not only tiny, it's pretty much negative, since any message it
> could provide would be too generic to be of much use, versus raising your
> own relevant exception message.
>

Indeed, especially when you can write this once at the top of your module,
or in a utils module in a larger package:

def unreachable():
    raise AssertionError

and then Jean's example can be spelled:

match args:
     case [Point2d(x, y)]:
         ...
     case ...:
         ...
     case ...:
         ...
     case ...:
         ...
     case _:
         unreachable()

Same benefit of a plain English word, identical behavior, very very tiny
downside of two parentheses and a two-line function definition, and zero
breakage or compatibility issues.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/YNUJL3BUA7Z2UNQ7ECITTYEKX6U7SUQA/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to