> On 30 Sep 2021, at 17:25, Soni L. <fakedme...@gmail.com> wrote: > > Alright, some ppl asked us to rephrase this, so: > > The plan is to take the function syntax: > > def name(args): > > and add an optional "with" to it: > > def name(args) with exceptions: > > these then get added to the function, similar to e.g. default args. when > an exception is thrown*, the VM then checks these and converts relevant > exceptions into RuntimeError, e.g.: > > def foo(): > raise Bar > def baz() with Bar: > foo() > baz() > > would make a RuntimeError, because foo raised a Bar and the VM sees that > Bar is in baz's with.
Does with Bar mean that Bar is expected? If so who cares if foo raises it? Are you really saying I cannot call functions to implement a complex algorithm that raises exceptions? The caller of baz is expecting Bar right? > > *except "raise" opcodes SKIP checking these (within the context of the > function), so the following: > > def baz() with Bar: > raise Bar > baz() > > raises a Bar, not a RuntimeError from a Bar. You want to include the exceptions that a function can raise in its signature and have python enforce rules based on that information. C++ had/has this feature and it failed in practice so it has been deprecated. I'd be surprised that it will be useful in python given this experience in the C++ world. Barry
_______________________________________________ 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/K52CEUI2EAHGK2NSGUOM2OHW66MNZ377/ Code of Conduct: http://python.org/psf/codeofconduct/