ANNOUNCE: 'goto' for Python

Tim Peters tim.one at comcast.net
Sat Apr 3 11:50:17 EST 2004


[Roger]
>> http://www.fortran.com/come_from.html
>> http://c2.com/cgi/wiki?ComeFrom
>> http://aspn.activestate.com/ASPN/CodeDoc/Acme-ComeFrom/ComeFrom.html

[Richie Hindle]
> Thanks for the references!  It's a bit of an embarrassment for the
> Python community that it's taken us so long to catch up.

Guido has already accepted your module for inclusion in Python 2.4, and I
expect he'll use his time machine then to ensure that it's always been part
of Python.

> And it's a bit of an embarrassment for me that I didn't implement
> "goto <linenumber>" or "comefrom <linenumber>" - I'll implement those
> in the next release.

That would be confusingly low-level.  If you haven't used Fortran, you may
not have realized that Clark's examples never used line numbers.  In
Fortran, you have the option of putting a non-negative integer in columns 1
through 5 of a statement.  There are no restrictions on the integers you can
put there (e.g., they needn't bear any relation to line number, and don't
even have to be increasing top-to-bottom), except that no two statements can
have the same integer attached.  So Clark *was* using labels, not line
numbers -- they're simply integer labels.  Your introduction of alphanumeric
labels to Python is already far advanced.

I must say, though, that the restriction to 5 digits in Fortran had the nice
Pythonic effect of discouraging a subroutine from containing more than a
hundred thousand branch targets (if you wanted more than that, you had to
play obscure tricks to worm around the no-more-than-1E5-labels restriction,
and that had a healthy moderating effect -- sad to say, most programmers
start to lose track after just a few tens of thousands of branch targets!).

BTW, because Fortran ignored whitespace, these labels were all the same:

123
  123
 123
01 23
1 2 3
00123

> (Computed and conditional comefroms are already on the list, as are
> computed labels, which I'm surprised to see missing from Clark's paper.
> His "assigned COME FROM" is almost the same thing, but I found it
> confusing - computed labels seem like a much clearer way of achieving
> the same thing.)

As above, the conflict is an illusion:  Clark is also using labels, they're
just integer labels.  Full speed ahead!





More information about the Python-list mailing list