Re: goto's, and loops

new topic     » goto parent     » topic index » view thread      » older message » newer message

Right I understand that this is true but that would mean that you would be
doing what is known as inline error checking in large programs you might
want to deploy an error handler which is centrally located and handles
multiple errors.  When I made the statement is was not directed to any one
programming language it is a general observation of several programming
languages.  Besides lets say that the error is not fatal and it is possible
for your application to continue by giving your user another option to use.
While yes you can use what you suggested and close the program but in an
event driven application you don't always know what the user is going to do
or what others programs are going to effect yours like MS *.dll's, not only
that but you don't want to duplicate code so send it to a central location
and handle the error.   So you must trap for all of these errors and if they
are fatal then yes have your program gracefully bow out with an error
message and abort but if not then let some error handler routines try to
work around the error or continue with the error by the above mentioned way.
That's where it might be prudent for the programmer to use a goto to bypass
code that your program knows will fail and use a different procedure to
perform the same method or prompt the user and ask what to do next for
example lets say that you are writing a routine for the user to open a file
and your program cannot find the file then you would send it to the error
handler with and error code and prompt the user for the file that is missing
then bypass the previous statement with a goto and continue to the next
procedure.  Most languages that are very event driven (ie..VB,Delphi, most
visual programming languages for GUI's) use these methods so that even with
an error the program can still successfully accomplish the job.

If there is any other questions about gotos you can reach me off the list at
jkinsey at bellsouth.net

Here is the deal.

A) don't assume that I know what I am talking about.
B) don't assume anything at all.
C) There is a reason why the developer of the language put every keyword in
the language
D) The easiest way only looks easy at first.
E) If you use a goto then heavily document your code so that even your dog
would understand what you are trying to accomplish and when you are finished
documenting it you will probably find that you didn't need it and replace it
with another structure anyway.
F) Keep an open mind the worst thing that you can do is go into a program
that has been written with gotos and start deleting everyone that you find
without reading the code.  especially if you are not used to reading gotos
and really hate them.
G) This comment is only here to finish the byte so that the last ones will
look like a word.

Thankssmile
JKinsey



-----Original Message-----
From: Euphoria Programming for MS-DOS
[mailto:EUPHORIA at LISTSERV.MUOHIO.EDU]On Behalf Of Bernie Ryan
Sent: Sunday, August 08, 1999 11:06 AM
To: EUPHORIA at LISTSERV.MUOHIO.EDU
Subject: Re: goto's, and loops


>>  If I remember right the only place to use a goto would be in an error
>>trapping routine where you would not want the routine to return back to
>>the next line after the error but instead break out and give an user
>>error then quit.  Other than that I cannot think of any structured modern
>>day

You don't need a goto for the above just print the error and
use the Euphoria abort.

Bernie

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu