[Oberon] EXIT statement?

Paul Reed paulreed at paddedcell.com
Fri Aug 29 14:17:37 CEST 2014


Hi Matic,

> Does anyone know the reasoning behind functionality of the EXIT statement?
> Why does it only work inside a LOOP statement and not inside WHILE and
> FOR?
> And also why is there no CONTINUE statement (as in C, Python, ...) , to
> skip to
> the next iteration of a loop?
>
> Is there some inherent drawback/downside in adding this to the language?
>
> I'm looking into the OP2 compiler to see if I can add a few features that
> I like or that seem
> quite useful for my needs.

EXIT is a necessary evil in LOOP statements because there is no other way
of getting out; but it is unstructured, similar to (good old GOTO and)
being able to RETURN from anywhere in a function (unstructured, as in, try
reading someone else's code).

Prof. Wirth corrected these shortcomings in Oberon-07, by removing LOOP
entirely and making RETURN syntactically part of the end of the function. 
As a concession, he added the Dijkstra alternate
WHILE...DO...ELSIF...DO...END form.

FWIW, my personal experience is that I never ultimately regretted not
adding a tempting "improvement" to any of my compilers ;-)

HTH
Paul





More information about the Oberon mailing list