8
$\begingroup$

While tracing the history of the BREAK and CONTINUE statements found in popular languages, I ran into a dead end right around ALGOL.

Algol _? -> CPL -> BCPL -> C -> C++ -> Java -> JavaScript

What was the first programming language to introduce the feature of being able to break out of a loop from the body?

This feature existed in BCPL and is implied to have existed (from its manual) in CPL which was introduced in 1963.

ALGOL 60 was CPL's main influence, but ALGOL 60 did not have the feature.

The structured programming movement started around 1966.

Given the turmoil in the committee between ALGOL 60 and ALGOL 68 (which spawned many languages), was this the source of the feature? Did it exist under a different form at the time as a block EXIT perhaps?

$\endgroup$
1
  • $\begingroup$ Maclisp and various other dialects of Lisp, including Lisp Machine Lisp had special form return, which serves the same purpose break does in C-like languages. Wiki says Maclisp was around since mid-sixties, but I certainly wasn't around to tell for sure who the inventor was. $\endgroup$ – wvxvw Jan 18 '16 at 0:57
9
$\begingroup$

I sent an email to Martin Richards to try and get some details/context about CPL and he gave me a reply. To partially quote:

"CPL did have a break command to cause an exit from a repetitive command such as while or until. As far as I remember it did not have an equivalent of continue, but the equivalent loop command was added to BCPL early in 1967."

[...]

"The introduction of break in CPL was almost certainly influenced by Dijkstra's paper..."

He also pointed me to the following document (see page 5):

http://www.cl.cam.ac.uk/~mr10/cpl2bcpl.pdf

$\endgroup$
-1
$\begingroup$

I nominate Konrad Zuse's Plankalkül, developed in the early 1940s. It is somewhat debatable whether this is a valid answer, since the language was not actually implemented until the '70s. But it had the equivalent to a break (actually closer to return in Lisp, which doesn't mean "return from the current function" as it does in other languages). Here is Zuse's description from his book about the language (translated to English):

Some plans[1] can be canceled before they have been fully calculated, because the desired result has already been produced, or because further computation turns out to be unnecessary. For example, a multi-part disjunction can be terminated as soon as one part is true, and a multi-part conjunction as soon as one part is false. Therefore an end-marking variable[2] $\mathrm{Fin}$ is introduced.

[Confusing example omitted.]

However, this kind of representation makes sense only if repetition plans[3] are used or if individual conjunctive/disjunctive elements making up a plan are very complicated.

Normally, the range of the $\mathrm{Fin}$ sign extends over the whole plan. But the intention may be to skip only part of the plan, while still calculating the following parts. In this case, it is necessary to separate the plan into groups of partial plans, so that the $\mathrm{Fin}$ applies only to the desired part.

Plans containing $\mathrm{Fin}$ may be nested multiple times. It can then be indicated by $\mathrm{Fin}^1$, $\mathrm{Fin}^2$, etc. whether the symbol applies only once or also at a higher level. This is particularly important in repetition plans.

An expression following a ${\lower{2pt}{\rightarrow}\atop\kern{-1.5pt}\raise{2pt}{.}}$ sign[4] is considered to be a closed part of the plan.

Notes:

  1. Zuse used "plan" (German Plan) to mean what we today might call an "expression", "statement", "program", "subprogram", etc. Note that the language is named Plankalkül, which means something like "plan calculus" (the calculus of plans).

  2. I think you can read "variable" as "identifier" or "symbol" here.

  3. A repetition plan (German Wiederholungsplan) is a loop.

  4. In Zuse's language, conditional execution is expressed in a way remarkably like McCarthy's M-Expressions: An expression of the form $x{\lower{2pt}{\rightarrow}\atop\kern{-1.5pt}\raise{2pt}{.}}y$ causes $y$ to be executed only if $x$ is true.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.