Re: Re: Long Live GOTO

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 6, 2012 at 11:28 AM, Larry Martell
<larry@xxxxxxxxxxxxxxxxxxxxx>wrote:

> On Mon, Feb 6, 2012 at 9:23 AM, Alain Williams <addw@xxxxxxxxxxxx> wrote:
> > On Mon, Feb 06, 2012 at 11:12:53AM -0500, Jim Giner wrote:
> >> NO "GO"!
> >> As one who started back in the 70's with old style coding that utilized
> GoTo
> >> in Cobol, Fortran, etc. and had to deal with "spaghetti code" written by
> >> even earlier developers who never considered that someone else would
> have to
> >> maintain their code, I feel strongly that GoTo is not to be used.
> >
> > I remember being faced with spaghetti code 35 odd years ago - yes,
> horrible.
> > But what do we mean by ''spaghetti code'' ? I remember code where every
> 3rd
> > statement was some form of GOTO - yuck!
> >
> > One very desirable feature of code is that it be clear, ie: lucid, able
> to be
> > understood by others. Too many GOTO statements and it is hard.
> >
> > However: a few GOTOs can make things clearer.  Think of a function that
> can fail
> > in several different places (eg data validation, ...).  But it is
> reading a file
> > which needs to be closed before the function returns.  I have seen code
> where
> > some $IsError variable is tested in many places to see if things should
> be done.
> > That is just as bad as lots of GOTO -- often when having to write
> something like
> > that I will have a GOTO (in several places) to the bottom of the
> function that
> > closes the file and returns failure.
> >
> > That is much clearer than extra variables.
> >
> > If I survey my code I find that I use one GOTO in about 4,000 lines of
> code -
> > that I do not find excessive.
> >
> > There are, however, people who consider any GOTO as communion with the
> devil.
> > IMHO: not so - if used sparingly.
>
> Just for another data point, the FAA does not allow gotos in any code
> that goes into an airplane.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Can I have the source for this so I can read the rationale? I'm curious
which language implementation it's referencing (C, Ada, etc.) and what
restrictions the language places on the construct. Again, the PHP version
of the construct is beneficially quite restrictive. For instance, some
people don't like giving programmers access to pointers just because you
can get into so much trouble with them, but I wonder if they'd be concerned
about Go's pointers, which don't allow pointer arithmetic, limiting one are
of potential trouble:

http://golang.org/doc/go_for_cpp_programmers.html#Conceptual_Differences

Interesting.

Adam

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux