Luke,
It used to be that GOTO was the only way to do things like loops in a
program (as it basically still is with CL). But injudicious use of GOTO can
create 'spaghetti code', where it's very difficult to figure out what's
going where, with lots of GOTO's skipping backwards and forwards. Once we
got 'better' alternatives, GOTO was 'outlawed' by many programmers as being
A BAD THING.
I guess I'd say that the odd GOTO here and there isn't the worst thing in
the world, but it's very rare that you'd need them anyway - there are
always better alternatives. Likewise with CABxx.
I think the key statement from your question is where you say "Sometimes it
is very readable IMHO..." Yes, sometimes it is. But as often as not, it
isn't very readable, and it's better/easier to just not use GOTO at all and
use a better alternative.
FWIW, lots of the alternatives are really GOTO's in disguise - ITER, LEAVE,
EXSR, LEAVESR and even the assorted DO and FOR loops. The underlying code
(MI for RPGIII, W-code for RPGIV, I think) generate complex GOTO-equivalent
statements. The difference is that we, the RPG programmers, don't see all
of that - all we see is, e.g. a nice FOR loop, without all the low-level
setting/checking/incrementing of variables.
Rory
On Mon, Sep 10, 2012 at 7:18 AM, Klugman, Luke
<LKlugman@xxxxxxxxxxxxxxxxx>wrote:
I don't understand -= since I have been programming in RPG I have always
got the impression that a GOTO is a no no and have never used it? BUT
what's so wrong with using it? I don't really understand why everyone
shuns it so much...
Sometimes it is very readable IMHO...
As an Amazon Associate we earn from qualifying purchases.