Skip to content

Commit 59f2741

Browse files
bpo-43199: Briefly explain why no goto (GH-24852)
Answer "Why is there no goto?" in the Design and History FAQ. (cherry picked from commit 5e29021) Co-authored-by: Terry Jan Reedy <[email protected]>
1 parent 1e7a47a commit 59f2741

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
@@ -599,7 +599,15 @@ sloppy and not write test cases at all.
599599
Why is there no goto?
600600
---------------------
601601

602-
You can use exceptions to provide a "structured goto" that even works across
602+
In the 1970s people realized that unrestricted goto could lead
603+
to messy "sphagetti" code that was hard to understand and revise.
604+
In a high-level language, it is also unneeded as long as there
605+
are ways to branch (in Python, with ``if`` statements and ``or``,
606+
``and``, and ``if-else`` expressions) and loop (with ``while``
607+
and ``for`` statements, possibly containing ``continue`` and ``break``).
608+
609+
One can also use exceptions to provide a "structured goto"
610+
that works even across
603611
function calls. Many feel that exceptions can conveniently emulate all
604612
reasonable uses of the "go" or "goto" constructs of C, Fortran, and other
605613
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)