home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!gatech!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!convex!tchrist
- From: Tom Christiansen <tchrist@convex.COM>
- Subject: Re: Problem with order of precedence, maybe
- Message-ID: <1992Jul30.150500.9873@convex.com>
- Originator: tchrist@convex.convex.com
- Sender: usenet@convex.com (news access account)
- Nntp-Posting-Host: convex.convex.com
- Reply-To: tchrist@convex.COM (Tom Christiansen)
- Organization: CONVEX Realtime Development, Colorado Springs, CO
- References: <sherman.712450219@foster>
- Date: Thu, 30 Jul 1992 15:05:00 GMT
- X-Disclaimer: This message was written by a user at CONVEX Computer
- Corp. The opinions expressed are those of the user and
- not necessarily those of CONVEX.
- Lines: 30
-
- From the keyboard of sherman@unx.sas.com (Chris Sherman):
- :Consider the following code:
- :
- :-----------------------------------------------
- :#!/usr/local/bin/perl
- :if (1 & 0 != 0) { print "1\n";}
- :if (0 & 1 != 0) { print "2\n";}
- :if (1 & 0 != 1) { print "3\n";}
- :if (0 & 1 != 1) { print "4\n";}
- :
- :if ((1 & 0) != 0) { print "and 1\n";}
- :if ((0 & 1) != 0) { print "and 2\n";}
- :if ((1 & 0) != 1) { print "and 3\n";}
- :if ((0 & 1) != 1) { print "and 4\n";}
- :-----------------------------------------------
- :
- :Besides the output, both sets of statements are similar, except for the
- :()'s on the bottom set.
-
- Check K&R: == and != bind more tightly than &. Unfortunately,
- they bind less tightly than &&, which is why people want get
- confused. I just tracked down a dozen cases of this in our
- kernel and utils source (in C).
-
- --tom
- --
- "GUIs normally make it simple to accomplish simple actions and impossible
- to accomplish complex actions." --Doug Gwyn (22/Jun/91 in comp.unix.wizards)
-
- Tom Christiansen tchrist@convex.com convex!tchrist
-