8000 bpo-43199: Briefly explain why no goto (GH-24852) · python/cpython@5e29021 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5e29021

Browse files
authored
bpo-43199: Briefly explain why no goto (GH-24852)
Answer "Why is there no goto?" in the Design and History FAQ.
1 parent bd2fa3c commit 5e29021

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Doc/faq/design.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,15 @@ test cases at all.
600600
Why is there no goto?
601601
---------------------
602602

603-
You can use exceptions to provide a "structured goto" that even works across
603+
In the 1970s people realized that unrestricted goto could lead
604+
to messy "sphagetti" code that was hard to understand and revise.
605+
In a high-level language, it is also unneeded as long as there
606+
are ways to branch (in Python, with ``if`` statements and ``or``,
607+
``and``, and ``if-else`` expressions) and loop (with ``while``
608+
and ``for`` statements, possibly containing ``continue`` and ``break``).
609+
610+
One can also use exceptions to provide a "structured goto"
611+
that works even across
604612
function calls. Many feel that exceptions can conveniently emulate all
605613
reasonable uses of the "go" or "goto" constructs of C, Fortran, and other
606614
languages. For example::
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Answer "Why is there no goto?" in the Design and History FAQ.

0 commit comments

Comments
 (0)
0