# [Python-3000] Announcing PEP 3136

Terry Reedy tjreedy at udel.edu
Wed Jul 4 01:40:14 CEST 2007

```"John S. Yates, Jr." <john at yates-sheets.org> wrote in message
news:j1gk83hfeltf7uqi0u4b5tpgbg80qg3cp0 at 4ax.com...
| On Tue, 3 Jul 2007, "Guido van Rossum" <guido at python.org> wrote:
|
| >However, I'm rejecting it on the basis that code so complicated to
| >require this feature is very rare.
|
| I assume that you are familiar with Donald E. Knuth's classic paper:
|  "Structured Programming with go to Statements"
|  http://pplab.snu.ac.kr/courses/adv_pl05/papers/p261-knuth.pdf

Do you consider this  to be for or against the PEP?  Rereading it....

At least half Knuth's goto examples are covered by Python's single level
restricted gotos:

Example 1 (switched to 0-bases arrays, not tested):

for i in range(m):
if A[i] == x: break
else:
A[m] = x
B[m] = 0
m += 1
B[i] += 1

Example 5 (ditto):

i = 0 #? initial value not given
while True:
if A[i] < x:
if L[i] != 0:
i = L[i]; continue
else:
L[i] = j; break
else: # > x
if R[i] != 0:
i = R[i]; continue
else:
R[i] = j; break
# dup code could be factored with LR = L or R as A[i] < or > x
A[j] = x
L[j] = R[j] = 0
j += 1

The rest are general gotos, including jumps into the middle of loops.
None are multilevel continues or breaks.

tjr

```

More information about the Python-3000 mailing list