Skip to content

Instantly share code, notes, and snippets.

Last active Jul 27, 2016
What would you like to do?

Introducing Goto

  • Proposal: SE-0666
  • Author: Erica Sadun
  • Status: Draft
  • Review manager: Crusty


This proposal introduces goto to Swift.


In a nutshell, the tl;dr of this is "Mike Ash dared me."

Introducing "goto" permits a one-way transfer of control to another point in code under a common scope. Wikipedia writes: "Many languages support the goto statement, and many do not." Right now Swift does not.

Swift is an opinionated language, and in its opinion, all the effort people go to just to avoid a simple goto places an undue burden on coders, especially on Monday mornings with suboptimal levels of coffee.

Detailed Design

  • Swift already supports labels for continue and break.
  • Labels are extended to any point in code, not just at loops.
  • A goto statement redirects execution to that label.


goto label

Impact on Existing Code

This proposal is purely additive. Theoretically it could break any code that uses goto as a symbol but it's self evident that anyone who has done so deserves to have their code broken.

Alternatives Considered

comefrom is computationally less practical.


This comment has been minimized.

Copy link

@jeremy-w jeremy-w commented Jul 12, 2016

Follow-up: Allow storing labels in label references. This enables straightforward implementation of an indirect-threaded interpreter, and would be analogous to the GCC extension "Labels as Values".


This comment has been minimized.

Copy link

@stephentyrone stephentyrone commented Jul 12, 2016

A necessary feature for any systems programming language!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment