Message99911
On Mon, Feb 22, 2010 at 6:51 PM, Jeremy Hylton <report@bugs.python.org> wrote:
> There's no reason we couldn't revise the language spec to explain that
> except clauses and comprehensions are block statements, i.e.
> statements that introduce a new block.
However (even apart from the below example) it would be tough to
implement cleanly in CPython.
> For the except case, there would be some weird effects.
>
> y = 10
> try:
> ...
> except SomeError as err:
> y = 12
> print y # prints 10
>
> In the example above, y would be a local variable in the scope of the
> except handler that shadows the local variable in the block that
> contains the try/except. It might be confusing that you couldn't
> assign to a local variable in the except handler without using a
> nonlocal statement.
Yeah, there are all sorts of problems with less-conspicuous nested
scopes like this, for a language that defaults to local assignment
like Python. Hence the horrible hacks.
>> As long as we don't have nested blocks, I think it's okay to see the limitation on (implicit or explicit) "del" of a cell variable as a compiler deficiency and fix that deficiency.
>
> The general request here is to remove all the SyntaxErrors about
> deleting cell variables, right? Instead, you'd get a NameError at
> runtime saying that the variable is currently undefined. You'd want
> that change regardless of whether we change the language as described
> above.
Yeah, if we could kill those SyntaxErrors we can leave the rest as is. |
|
Date |
User |
Action |
Args |
2010-02-23 13:43:30 | gvanrossum | set | recipients:
+ gvanrossum, jhylton, rhettinger, terry.reedy, pje, amaury.forgeotdarc, benjamin.peterson, cmcqueen1975 |
2010-02-23 13:43:28 | gvanrossum | link | issue4617 messages |
2010-02-23 13:43:27 | gvanrossum | create | |
|