Date: Fri, 29 Jan 1999 20:22:33 -0000 From: paul@originative.co.uk To: julian@whistle.com, imp@village.org Cc: akm@zeus.theinternet.com.au, current@FreeBSD.ORG Subject: RE: btokup().. patch to STYLE(9) (fwd) Message-ID: <A6D02246E1ABD2119F5200C0F0303D10FDEB@octopus>
next in thread | raw e-mail | index | archive | help
> -----Original Message----- > From: Julian Elischer [mailto:julian@whistle.com] > Sent: 29 January 1999 17:48 > To: Warner Losh > Cc: Andrew Kenneth Milton; current@FreeBSD.ORG > Subject: Re: btokup().. patch to STYLE(9) (fwd) > > > > > On Fri, 29 Jan 1999, Warner Losh wrote: > > > > if ((a < 0) && (b < 0)) > > > Personally while I KNOW (after wasting a second thinking > about it) that > the example below is the same as that above, I ALWAYS code as above. > It takes me about 1/5th the time to know what it means. > > > if (a < 0 && b < 0) > > If I were working on this code written by someone else it'd leave my > editor looking like the top example, that's for sure. I think that > "How easy is it to edit a piece of code and still have it do what you > expect" is an important consideration, because people DO edit things. > > > > > > > I do agree that complex things like: > > > > if (a | b & c % d ^ e) > > > > should really have some parents to show what is going on. > > I have NO idea of what that is doing and I have plans of > looking it up in > the book to work it out.. The interesting thing about this example, and there's probably something in this, is that the first example is trivial to understand without parens because it parses left to right as an English expression i.e. if (a < 0 && b < 0) "if a is less than 0 and b is less than 0" It mirrors the way we read spoken language so it's very quick to see what's going on. With the more difficult expression if (a | b & c % d ^ e) there's no spoken language analogy that flows left to right so we have to parse it in much the same way as the compiler does. I bet that most people are mentally putting braces around the expressions to break it up or at least something along those lines. Therefore it makes sense to actually put the parens there in the first place so that people can parse it more quickly with the naked eye. Paul. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?A6D02246E1ABD2119F5200C0F0303D10FDEB>