GOTO w/ Python?
donn at drizzle.com
Fri Jun 21 06:44:47 CEST 2002
Quoth Jerzy Karczmarczuk <karczma at info.unicaen.fr>:
| 3. No, in order to speak about genuine gotos *you don't need to think
| What you need is to understand correctly the notion of continuation
| (something quite standard - again - in the Functional Programming
| world). This is a high-level model of "flat" branching, but may be
| used to more exquisite constructions, such as backtracking.
The stackless branch of python supported a very rich set of
continuation options. I use the past tense, because it seems
to have been a little too powerful for even the mainly feature
hungry python crowd, so current development of stackless has
dropped most of that stuff. I hope we're talking about the same
thing - these continuations suspend and resume computations like
a kind of serialized multi-threading.
For me, genuine gotos are only a matter of flow control along the
same lines as "while" loops. Internal to a computation, if you
will - one doesn't goto out of or into a procedure. I think in
some sense of "ideal", an ideal procedural language would have goto,
because it expresses some problems most directly and the need to
emulate it with "while" or "try" makes worse code. The branching
in a goto construct is perfectly apparent, it just can be harder
to get an overall sense of the flow if goto is over-used. Why,
even our beloved python itself had a few judiciously used gotos
last time I looked.
Continuations I'm not so sure about. I wrote some stackless stuff
that made really interesting (to me, anyway) use of them, but now
we're talking about flow of control that really is easy to misunderstand.
| I don't believe that there are any technical difficulties in the
| implementation of gotos at the low level. At the high level this
| is then a question of the language structure, as seen by Van Rossum,
| the lack of gotos was a conscious decision.
If Michael Hudson says there are technical difficulties, I would
take that as fact, but a fact about Python's current internals.
If goto had been wanted, I'm sure Python's design could have
Donn Cave, donn at drizzle.com
More information about the Python-list