diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-03-15 04:21:52 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-15 04:21:52 (GMT) |
commit | 59f2741c4a1a53d4122d2cb512337f4b88619de9 (patch) | |
tree | 02a94b9f397a3b94b06ebb762d1ea800db4c97df /Doc | |
parent | 1e7a47ab86d5d6a5103e67ba71389f6daa18ea2d (diff) | |
download | cpython-59f2741c4a1a53d4122d2cb512337f4b88619de9.zip cpython-59f2741c4a1a53d4122d2cb512337f4b88619de9.tar.gz cpython-59f2741c4a1a53d4122d2cb512337f4b88619de9.tar.bz2 |
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@udel.edu>
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/faq/design.rst | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst index f91b51b..65d6a8e 100644 --- a/Doc/faq/design.rst +++ b/Doc/faq/design.rst @@ -599,7 +599,15 @@ sloppy and not write 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:: |