>>>>> "PS" == Peter Scott <pe...@psdt.com> writes:

  PS> On Wed, 13 Apr 2011 21:57:53 -0700, Mariano Loza Coll wrote:

  >> Like Owen, I've come across many a recommendation AGAINST using goto in
  >> Perl. And (like Owen?), I have yet to find one that explains clearly the
  >> reasons arguing against its use. If nothing else, it has made me very
  >> curious... Can any of the more experienced programmers (ie. nearly
  >> everyone else on this list by my standards) point to a good explanation
  >> as to why one should avoid goto in Perl (or coding in general)? I looked
  >> around in perl-begin.org but couldn't find anything obvious. Once again,
  >> I make my request from the purest desire of learning Perl the best way I
  >> can.

  PS> Here is the definitive explanation: http://www.cs.utexas.edu/users/EWD/
  PS> ewd02xx/EWD215.PDF .

having heard about that article for many years it was interesting to
read it. it may be over the head of some members here but useful to read
anyway. it doesn't go into any practical reasons why goto is bad. it
just says the logical complexity (his index data) goes way up with gotos
but stays reasonable with high level flow controls
(if/else/while/sub/etc.).


  PS> I have never, ever, seen a situation where the use of goto would have 
  PS> resulted in clearer code.  Considering it has always indicated to me that 
  PS> the person considering it has not understood the problem properly or 
  PS> modeled its solution well.  Goto simply is not part of the vocabulary of 
  PS> clear coding.

agreed. but teaching how to avoid gotos is important too. a classic
newbie style was to use many boolean variables and loop and check them
all over and over. that is just as bad as using gotos.

here are my rules on this and they illustrate why goto is bad without
the complexity issues brought up in that article.

        code is for people, not computers.
        code is for other people, not yourself.

anyone can (eventually) code up a program that works. better programmers
code so other programmers can understand what they were doing and can
easily maintain that code. gotos make that hard to do as they break all
sorts of rules like isolation and cause action at a distance issues. you
write subs and modules to form abstract operations that can be
understood as single entities. goto makes everything into one large
fugly program where anything goes (pun intended) anywhere.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to