Danceswithmice wrote:
The idea is that YOU write "local:", and the interpreter, without you
ever seeing it, promotes that into a hidden function with a hidden
name and a hidden call.
---
p.f.moore wrote:
That would make "return" in the local scope exit the scope, not the
enclosing function. Which is almost certainly not what people would expect
from a "local scope" statement.
Hence my remark about return and yield requiring attention. These
would be disallowed in the context of "local:" UNLESS there is an
enclosing scope of "def function():", so there's no issue of what they
do if they are simply mainlined, and (I think) a well defined result
if they are not.
What about getting an untrapped exception? Again, your suggestion would
mean that only the local scope is exited. Again, this would be unexpected.