[Python-Dev] Re: anonymous blocks
Samuele Pedroni
pedronis at strakt.com
Wed Apr 27 15:48:24 CEST 2005
Jim Fulton wrote:
> Duncan Booth wrote:
>
>> Jim Fulton <jim at zope.com> wrote in news:426F7A8F.8090109 at zope.com:
>>
>>
>>> Guido van Rossum wrote:
>>>
>>>> I've written a PEP about this topic. It's PEP 340: Anonymous Block
>>>> Statements (http://python.org/peps/pep-0340.html).
>>>>
>>>
>>> Some observations:
>>>
>>> 1. It looks to me like a bare return or a return with an EXPR3 that
>>> happens to evaluate to None inside a block simply exits the
>>> block, rather
>>> than exiting a surrounding function. Did I miss something, or is
>>> this a bug?
>>>
>>
>>
>> No, the return sets a flag and raises StopIteration which should make
>> the iterator also raise StopIteration at which point the real return
>> happens.
>
>
> Only if exc is not None
>
> The only return in the pseudocode is inside "if exc is not None".
> Is there another return that's not shown? ;)
>
> I agree that we leave the block, but it doesn't look like we
> leave the surrounding scope.
that we are having this discussion at all seems a signal that the
semantics are likely too subtle.
More information about the Python-Dev
mailing list