home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / perl / 5478 < prev    next >
Encoding:
Text File  |  1992-08-25  |  1.8 KB  |  53 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!caen!sol.ctr.columbia.edu!eff!ckd
  3. From: ckd@eff.org (Christopher Davis)
  4. Subject: Re: Using Gotos?
  5. In-Reply-To: dave@pipi.iis.u-tokyo.ac.jp's message of Tue, 25 Aug 1992 09:23:57 GMT
  6. Message-ID: <CKD.92Aug25172112@loiosh.eff.org>
  7. Sender: usenet@eff.org (NNTP News Poster)
  8. Nntp-Posting-Host: loiosh.eff.org
  9. Organization: Electronic Frontier Foundation Tech Central
  10. References: <DAVE.92Aug25182357@pipi.iis.u-tokyo.ac.jp>
  11. Distribution: comp
  12. Date: Tue, 25 Aug 1992 21:21:16 GMT
  13. Lines: 38
  14.  
  15. David> == David Wuertele <dave@pipi.iis.u-tokyo.ac.jp> 
  16.  
  17.  David> P.S. I have been equating "next LABEL;" with GOTO, perhaps
  18.  David> mistakenly.  Please flame if I'm being naive.
  19.  
  20. At least one semi-religious article on structured programming that I've
  21. read said that transferring control to the end of a block is not, by
  22. definition, a GOTO of any sort (even if it's implemented with a GOTO),
  23. but merely an early escape from the block.
  24.  
  25. next is definitely such, and (IMHO) increases clarity; try these:
  26.  
  27. while (<>) {
  28.      next if /^#/;
  29.      &munge($_);
  30.      &kludge($_);
  31.      &many_lines_of_code;
  32. }
  33.  
  34. while (<>) {
  35.      if (!/^#/) {
  36.           &munge($_);
  37.           &kludge($_);
  38.           &many_lines_of_code;
  39.      }
  40. }
  41.  
  42. In the second, it is not immediately clear that you intend to totally
  43. ignore the line; the many_lines_of_code might obscure an else or elsif
  44. clause, and you won't know 'till you scroll down.  The two are logically
  45. equivalent, but differ in readability.
  46.  
  47. I'm not gonna flame you; you certainly haven't done anything deserving
  48. of it... but you really shouldn't dismiss next/last/redo out of hand.
  49. --
  50. Christopher Davis * ckd@eff.org * System Administrator, EFF * +1 617 864 0665
  51.             ``Ed Gruberman, you fail to grasp Ti Kwan Leep.
  52.             Approach me that you might see.'' -- The Master
  53.