× 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/25/2013 2:03 PM, CRPence wrote:
On 25 Jul 2013 10:23, paultherrien@xxxxxxxxxxxxxxxxxx wrote:
So isn't using leave with a CMDLBL just a 'GOTO'?

In effect, for the processing of the code, yes they can be identical.
However as coded in the source, for the effect of the compile, they can
be somewhat dissimilar. If the code with the LEAVE is ever copied or
moved, the compiler can catch an inherently illogical change, whereas
that is effectively impossible with a GOTO which can go anywhere; only
duplicate labels will be caught for both. Move a nested iterative out
of its current nesting, and the referenced CMDLBL will cause the compile
to fail, but the GOTO will not fail, and will almost surely cause nasty
run-time effects.

This may sound theoretical but the truth is that we midrangers have
ignored computing theory for too long, and to our peril.

The problem isn't this one program with this one circumstance. The
problem is the habits we train ourselves to use. Over and over, we
repeat the same patterns. If it's a good pattern, then design,
construction and maintenance are all easier. If it's a bad pattern, we
plant another land mine we'll be tiptoeing around in a month.

GOTO isn't bad because four letter words are naughty. GOTO is bad
because it disrupts the linear flow of processing in an unpredictable
way. Unpredictable, that is, until you analyse the code. This adds
work to your workday - what John Seddon calls 'Failure Demand'. Instead
of spending time making the program better, we're spending time sussing
out how it works. And we'll do that almost every time we have to touch
the darned thing.

Yes, LEAVE does /mostly/ the same thing as GOTO, but it's way more
predictable - the analysis takes less time to do. We can still plant
land mines by having multiple early exits, for multiple reasons, and
that sort of loop is arguably harder to analyse than a short loop with a
GOTO whose target is immediately below the loop's end.

Strict adherence to absolute rules is intended to help a raw beginner
through that difficult learning period when everything seems a mass of
indecipherable decision points, any one of which will destroy the
organisation's database. As one gains in expertise, one understands
that these rules are mostly guidelines. When one becomes an expert, one
invents the rules for beginners to follow. It's a natural progression,
and beginners need not feel shame at their state - all of us were there
and all of us needed those rules to keep sane.

Sometimes, it makes logical sense to leave a loop early. Given the
multiple ways to do that, LEAVE seems the most useful and carries the
lightest analytical load compared to the alternatives. I don't always
exit a loop early, but when I do, I use LEAVE.
--buck

As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.