]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43199: Briefly explain why no goto (GH-24852)
authorTerry Jan Reedy <tjreedy@udel.edu>
Sun, 14 Mar 2021 22:12:04 +0000 (18:12 -0400)
committerGitHub <noreply@github.com>
Sun, 14 Mar 2021 22:12:04 +0000 (18:12 -0400)
Answer "Why is there no goto?" in the Design and History FAQ.

Doc/faq/design.rst
Misc/NEWS.d/next/Documentation/2021-03-13-18-43-54.bpo-43199.ZWA6KX.rst [new file with mode: 0644]

index 7fe1c6d58f58a12d3fbb202117126afe9d28dc61..f1f54eff86e87c0339b070812872134dc3f02279 100644 (file)
@@ -600,7 +600,15 @@ test cases at all.
 Why is there no goto?
 ---------------------
 
-You can use exceptions to provide a "structured goto" that even works across
+In the 1970s people realized that unrestricted goto could lead
+to messy "sphagetti" code that was hard to understand and revise.
+In a high-level language, it is also unneeded as long as there
+are ways to branch (in Python, with ``if`` statements and ``or``,
+``and``, and ``if-else`` expressions) and loop (with ``while``
+and ``for`` statements, possibly containing ``continue`` and ``break``).
+
+One can also use exceptions to provide a "structured goto"
+that works even across
 function calls.  Many feel that exceptions can conveniently emulate all
 reasonable uses of the "go" or "goto" constructs of C, Fortran, and other
 languages.  For example::
diff --git a/Misc/NEWS.d/next/Documentation/2021-03-13-18-43-54.bpo-43199.ZWA6KX.rst b/Misc/NEWS.d/next/Documentation/2021-03-13-18-43-54.bpo-43199.ZWA6KX.rst
new file mode 100644 (file)
index 0000000..d1b454f
--- /dev/null
@@ -0,0 +1 @@
+Answer "Why is there no goto?" in the Design and History FAQ.