do things like loops in a program (as it basically still is with CL).
--> WAS before Release V5R3
Since V5R3 even CL has DOWHILE, DOUNTIL and DOFOR loops including ITERATE
and LEAVE commands and Subroutines and leave subroutines.
In well-structured modular programming there is no need to code a GOTO.
Everything can be done with loops, iter, leave, subroutines and LeaveSR and
(sub-)procedures and Return are used, which are finally (under the cover)
nothing else than GOTOs)
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im
Auftrag von Rory Hewitt
Gesendet: Monday, 10.9 2012 16:31
An: RPG programming on the IBM i / System i
Betreff: Re: GOTO in free form!
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...
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.