On Sat, Sep 26, 2020 at 6:56 AM Oscar Benjamin
<oscar.j.benja...@gmail.com> wrote:
>
> There are many common bugs that arise as a result of exceptions that
> are overlooked. There are also often simple ways to rewrite the code
> so that it becomes exception free. For example in sympy:
>
>     if x.is_positive:  # never raises (excepting bugs) - False if 
> indeterminate
>     if x > 0: # raises if indeterminate

The novice believes that his ultimate goal is to stop the program from
crashing. If "exception free" is your goal, then sure, this feature
will certainly help you. I don't want Python to have language support
for something that is primarily aimed at helping novices to remain
forever novices.

> That is *not* what I am suggesting. Rather only an explicit raises
> hint could give an error so the above is fine. The type checker knows
> that g might raise FooError but there's nothing wrong with raising an
> error without any declaration. However the type checker *would*
> complain about this:
>
> def f(): raises FooError
>     ...
>
> def g(): raises None
>     f()   # <--- typecheck error because g claims that it does not raise
>

Okay. So what exceptions can a "raises None" function raise? Or if it
"raises FooError", then what, other than FooError, can it raise? If
this is to have the blessing of the language, there needs to be an
absolutely 100% consistent answer to that question. And there's only
one valid answer that will always be correct, and it's the useless
one: BaseException.

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/RYCEOPKWRLRGSWAE5BB5FRC7PMFBSF4K/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to