Named code blockes
Steven D. Majewski
sdm7g at Virginia.EDU
Sat Apr 14 16:55:19 EDT 2001
On Sat, 14 Apr 2001, Alex Martelli wrote:
> I would. If one can break out of one level of loop with the break
> statement, why would exceptions be the 'designed' way to break
> out of two or three levels? It's not that rare a need. It's not an
> issue of optimization for me, but of clear and explicit expression
> of design intent.
I agree it's an issue of clear and explicit expression.
We just have a difference of opinion over whether labeled blocks
and multiple level breaks deliver on that clear and explicit expression.
I would actually find GOTO's *MORE* clear and explicit provided
everyone had the discipline to use them in a restricted and structured
manner. (ala. Knuth, Structured Programming with Goto)
Typically, a named block has the name label at the top -- which is
not usually where the control is flowing to, and you have to hunt
and peek around to find the next executable statement. What's clear
and explicit about that ?
A restricted use of GOTO is more (IMHO) clear.
try/except blocks come in somewhere in between Goto and named
blocks for readability. Not a bad compromise if you don't want
to rely on disciplined use of goto. The target is pretty clear.
( But maybe you're thinking of a different syntax for Python
than I can imagine from other lang. I've seen. If you show
me a clear example, I'll reconsider. )
-- Steve Majewski
More information about the Python-list
mailing list