[Python-checkins] bpo-43199: Briefly explain why no goto (GH-24852)

miss-islington webhook-mailer at python.org
Mon Mar 15 00:21:44 EDT 2021


https://github.com/python/cpython/commit/c3f03333c3a9c7aa213a463c5928d33fd4049060
commit: c3f03333c3a9c7aa213a463c5928d33fd4049060
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2021-03-14T21:21:36-07:00
summary:

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 5e29021a5eb10baa9147fd977cab82fa3f652bf0)

Co-authored-by: Terry Jan Reedy <tjreedy at udel.edu>

files:
A Misc/NEWS.d/next/Documentation/2021-03-13-18-43-54.bpo-43199.ZWA6KX.rst
M Doc/faq/design.rst

diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst
index 8cf271c302408..77c8ca9b6cb05 100644
--- a/Doc/faq/design.rst
+++ b/Doc/faq/design.rst
@@ -601,7 +601,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
index 0000000000000..d1b454fabd7f8
--- /dev/null
+++ b/Misc/NEWS.d/next/Documentation/2021-03-13-18-43-54.bpo-43199.ZWA6KX.rst
@@ -0,0 +1 @@
+Answer "Why is there no goto?" in the Design and History FAQ.



More information about the Python-checkins mailing list