Being a relative new comer to rpg, (being doing it for 10 yrs plus, but
still in my thirties), I came to the party long after the speghetti code
scenario! I kind of figured this was the case, but now adays where it is
not widely used or needed I have been in situations where I have been
tempted.
I have a dear colleague who loves them and still tries to sneak the odd
one in, and my one and only goto was a dedication to him : GOTO SID!,
(not his real name..!)
:-)
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Rory Hewitt
Sent: 10 September 2012 15:31
To: RPG programming on the IBM i / System i
Subject: 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.
-----------------------------------------------------------------------
The information contained in this email is confidential and may also contain privileged information. Sender does not waive confidentiality or legal privilege. If you are not the intended recipient please notify the sender immediately; you should not retain this message or disclose its content to anyone.
Internet communications are not secure or error free and the sender does not accept any liability for the content of the email. Although emails are routinely screened for viruses, the sender does not accept responsibility for any damage caused. Replies to this email may be monitored.
For more information about the Tullett Prebon group of companies please visit the following web site: www.tullettprebon.com
-----------------------------------------------------------------------
As an Amazon Associate we earn from qualifying purchases.