home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / perl / 5038 < prev    next >
Encoding:
Text File  |  1992-07-30  |  1.8 KB  |  48 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!gatech!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!convex!tchrist
  3. From: Tom Christiansen <tchrist@convex.COM>
  4. Subject: Re: Problem with order of precedence, maybe
  5. Message-ID: <1992Jul30.150500.9873@convex.com>
  6. Originator: tchrist@convex.convex.com
  7. Sender: usenet@convex.com (news access account)
  8. Nntp-Posting-Host: convex.convex.com
  9. Reply-To: tchrist@convex.COM (Tom Christiansen)
  10. Organization: CONVEX Realtime Development, Colorado Springs, CO
  11. References: <sherman.712450219@foster>
  12. Date: Thu, 30 Jul 1992 15:05:00 GMT
  13. X-Disclaimer: This message was written by a user at CONVEX Computer
  14.               Corp. The opinions expressed are those of the user and
  15.               not necessarily those of CONVEX.
  16. Lines: 30
  17.  
  18. From the keyboard of sherman@unx.sas.com (Chris Sherman):
  19. :Consider the following code:
  20. :
  21. :-----------------------------------------------
  22. :#!/usr/local/bin/perl
  23. :if (1 & 0 != 0) { print "1\n";}
  24. :if (0 & 1 != 0) { print "2\n";}
  25. :if (1 & 0 != 1) { print "3\n";}
  26. :if (0 & 1 != 1) { print "4\n";}
  27. :
  28. :if ((1 & 0) != 0) { print "and 1\n";}
  29. :if ((0 & 1) != 0) { print "and 2\n";}
  30. :if ((1 & 0) != 1) { print "and 3\n";}
  31. :if ((0 & 1) != 1) { print "and 4\n";}
  32. :-----------------------------------------------
  33. :
  34. :Besides the output, both sets of statements are similar, except for the
  35. :()'s on the bottom set. 
  36.  
  37. Check K&R: == and != bind more tightly than &.  Unfortunately,
  38. they bind less tightly than &&, which is why people want get
  39. confused.  I just tracked down a dozen cases of this in our
  40. kernel and utils source (in C).
  41.  
  42. --tom
  43. -- 
  44. "GUIs normally make it simple to accomplish simple actions and impossible
  45. to accomplish complex actions."   --Doug Gwyn  (22/Jun/91 in comp.unix.wizards)
  46.  
  47.      Tom Christiansen           tchrist@convex.com      convex!tchrist
  48.