home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / perl / 7576 < prev    next >
Encoding:
Text File  |  1992-12-22  |  1.0 KB  |  35 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!munnari.oz.au!metro!usage!news
  3. From: cameron@cs.unsw.oz.au
  4. Subject: quick /*NOTREACHED*/ hack for perl ...
  5. Message-ID: <cameron-921222133520-1-21899@fuligin>
  6. Sender: news@usage.csd.unsw.OZ.AU
  7. Nntp-Posting-Host: fuligin.spectrum.cs.unsw.oz.au
  8. Reply-To: cameron@cs.unsw.oz.au
  9. Organization: CS&E Computing Facility, Uni Of NSW, Oz
  10. Errors-To: cameron@cs.unsw.oz.au
  11. Date: Tue, 22 Dec 1992 02:35:42 GMT
  12. Return-Receipt-To: cameron@cs.unsw.oz.au
  13. Lines: 20
  14.  
  15. This is a runtime check, but can be scatter through code like the lint one,
  16. as a subroutine call, viz:
  17.     while (1)
  18.         { blah...; last # shouldn't happen ever
  19.           more blah ...
  20.         }
  21.  
  22.     &NOTREACHED;
  23.  
  24. The code:
  25.  
  26. sub NOTREACHED { local($package,$filename,$line)=caller;
  27.  
  28.                  die "$line of $filename (package $package) should not be reached";
  29.                }
  30.     - Cameron Simpson
  31.       cameron@cs.unsw.oz.au, DoD 0743
  32. --
  33. "The engine purrs beneath me with a purpose,
  34.  ready for the pleasure of my hand upon the throttle." - Peter Smith
  35.