home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / perl / 7758 < prev    next >
Encoding:
Internet Message Format  |  1993-01-11  |  1.9 KB

  1. Path: sparky!uunet!ogicse!reed!romulus!merlyn
  2. From: merlyn@ora.com (Randal L. Schwartz)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: bug with "last"
  5. Message-ID: <MERLYN.93Jan11120951@romulus.reed.edu>
  6. Date: 11 Jan 93 20:09:56 GMT
  7. Article-I.D.: romulus.MERLYN.93Jan11120951
  8. References: <cameron-930111155241-1-06364@fuligin> <1993Jan11.175416.3503@netcom.com>
  9. Sender: news@reed.edu (USENET News System)
  10. Organization: Stonehenge Consulting Services; Portland, Oregon, USA
  11. Lines: 29
  12. In-Reply-To: lgolding@netcom.com's message of Mon, 11 Jan 1993 17:54:16 GMT
  13.  
  14. >>>>> In article <1993Jan11.175416.3503@netcom.com>, lgolding@netcom.com (Laurence J. Golding) writes:
  15. Laurence>     Within the BLOCK of any compound loop statement, you may use ...
  16. Laurence>             last
  17. Laurence>             last LABEL
  18. Laurence>     ... If the LABEL is omitted, the loop control statement refers to
  19. Laurence>     the innermost enclosing loop.
  20.  
  21. Laurence> Now, in your example, the "{last;}" certainly does not look like a loop,
  22. Laurence> and the "for" certainly does look like the innermost enclosing loop.  So it
  23. Laurence> appears that the book should read:
  24.  
  25. Laurence>     ... If the LABEL is ommitted, the loop control statement refers to
  26. Laurence>     the innermost enclosing _block_.
  27.  
  28. Ahhh.  But it's not just a block, or the branches of an "if" would count.
  29.  
  30. So, we have three overloaded uses of curlies: an "if" branch, a naked
  31. block, and a traditional loop.  "last" applies to the last two, so
  32. we've collectively called them (defined in folklore) as "loops".  All
  33. three qualify as "blocks", using the C definition, so changing the
  34. Camel reference to "block" doesn't cut it.
  35.  
  36. OK, so the folklore should have been described. Sorry. :-)
  37.  
  38. { print "Just another Perl hacker,"; last; }
  39. --
  40. Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
  41. merlyn@ora.com (semi-permanent) merlyn@reed.edu (for newsreading only)
  42. factoid: "Portland, Oregon, home of the California Raisins and Lone-Star Beer!"
  43.