× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 7/23/13 4:17 PM, John McKee wrote:
I'm confused. I had a teacher, years ago, who was adamant - one way
in and one way out. How is LEAVE considered structured? Violates the
teacher's rule, since there are now multiple ways that a loop could be
exited. His preferred method was to test at the top.

Many years ago, there was a level of fanaticism involving structured programming, combined with a very primitive understanding of it. It was exemplified in the inordinate popularity of Pascal, which had no concept of "LEAVE," and only grudgingly included a GOTO.

This primitive understanding assumed, in particular, that under normal conditions, an indexed loop always runs to completion, and should only exit early in case of an irrecoverable error. In fact, there's an obvious exception to this: table look-up. This led to numerous cases in which programmers were forced to choose between (1) storing the "found" value and continuing to waste processor resources iterating uselessly (perhaps at least skipping the "meat" of the loop), (2) substituting a DOWHILE or DOUNTIL construct, and handling the counter manually, or (3) using a GOTO.

It's rather telling that when Niklaus Wirth, the ultimate structured programming maven, designed a language for actual production use (Pascal was never intended as more than a teaching language), it *did* have a "LEAVE" (I don't remember, offhand, what it was called).

At any rate, where GOTO allows transfer of control to any labeled statement (in some languages, like traditional BASIC, all statements have labels), possibly even including transferring *into* a loop or inner-block in a way that bypasses any initialization, LEAVE simply exits the current iterative structure, going "out" the same way it would normally exit on completion, while ITERATE simply aborts the current iteration without actually exiting the loop.

--
JHHL


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.