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

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!uwm.edu!ogicse!psgrain!m2xenix!agora!merlyn
  2. From: merlyn@ora.com (Randal L. Schwartz)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: quick /*NOTREACHED*/ hack for perl ...
  5. Message-ID: <MERLYN.92Dec25095229@agora.rain.com>
  6. Date: 25 Dec 92 17:52:29 GMT
  7. Article-I.D.: agora.MERLYN.92Dec25095229
  8. References: <cameron-921222133520-1-21899@fuligin>
  9. Sender: merlyn@agora.rain.com (Randal L. Schwartz)
  10. Organization: Stonehenge Consulting Services; Portland, Oregon, USA
  11. Lines: 22
  12. In-Reply-To: cameron@cs.unsw.oz.au's message of Tue, 22 Dec 1992 02:35:42 GMT
  13.  
  14. In article <cameron-921222133520-1-21899@fuligin> cameron@cs.unsw.oz.au writes:
  15.    sub NOTREACHED { local($package,$filename,$line)=caller;
  16.  
  17.             die "$line of $filename (package $package) should not be reached";
  18.           }
  19.  
  20. Or, you could use something like:
  21.  
  22. require 'assert.pl';
  23. sub NOTREACHED {
  24.     &assert("0 NOT REACHED"); # the 0 makes assertion false
  25. }
  26.  
  27. &NOTREACHED;
  28.  
  29. which gives you a good stack traceback as well.
  30.  
  31. sub NOTREACHED {print "Just another Perl hacker,";} &NOTREACHED;
  32. -- 
  33. Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
  34. merlyn@ora.com (semi-permanent) merlyn@agora.rain.com (for newsreading only)
  35. phrase: "Welcome to Portland, Oregon ... home of the California Raisins!"
  36.