home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!sun-barr!ames!news.hawaii.edu!uhunix.uhcc.Hawaii.Edu!todd
- From: todd@uhunix.uhcc.Hawaii.Edu (Todd Ogasawara)
- Subject: coding style (was Re: Perl language formatting conventions?)
- Message-ID: <1992Aug27.072110.24646@news.Hawaii.Edu>
- Sender: root@news.Hawaii.Edu (News Service)
- Nntp-Posting-Host: uhunix.uhcc.hawaii.edu
- Organization: University of Hawaii
- References: <DAVE.92Aug25141544@pipi.iis.u-tokyo.ac.jp> <1992Aug25.214800.10825@netlabs.com>
- Date: Thu, 27 Aug 1992 07:21:10 GMT
- Lines: 57
-
- In article <1992Aug25.214800.10825@netlabs.com> lwall@netlabs.com (Larry Wall) writes:
- >In article <DAVE.92Aug25141544@pipi.iis.u-tokyo.ac.jp> dave@pipi.iis.u-tokyo.ac.jp (David Wuertele) writes:
- >: What do youse all think?
-
- >That's a religious issue.
-
- >There's only one sure-fire way to be happy. Do what you know is right,
- >and don't expect everyone to like it.
-
- >Larry
-
- I agree with Larry's 2nd statement but am not sure I agree with the first
- totally. I admit that "style," by its very nature, has some degree of
- individualism. However, I suspect that there might be some way to quantify
- some (though not all) aspects of coding style to help programmers make
- source code easier for other people to read and interpret (or, for that
- matter, for the programmer him/herself at some time in the future).
-
- There were a few journal articles a number of years back trying to
- determine how varying indentation size affects code readability (I think
- the conclusion was that 4 spaces on a "standard" sized screen was optimal
- though I still prefer 8 spaces :-).
-
- There must also be some way to use some of the findings from vision
- on processing simple (curved vs. angular) and complex (alphanumeric and
- ideographic) images as a tie-in to things like parentheses placement.
- One thing I've found over the past few years is that I and some other
- people find placing a space after an openning paren and before a closed
- paren sometimes adds to the readability of the code (this is not a 100%
- rule, it is more like an "i before e except after c except in receive"
- rule). E.g., (from C)
-
- while ((c = getc(fpIn)) != EOF) {
- putc(c,fpOut);
- }
- vs.
- while ( ( c = getc(fpIn) ) != EOF ) {
- putc(c, fpOut);
- }
-
- Note that the "paren space" rule is not used 100% of the time in even a
- short piece of code like the one shown above.
-
- I also think that the use of parens even when they aren't needed (like the
- example above) aids readability. I.e., the code above is equivalent to
-
- while ( ( c = getc(fpIn) ) != EOF )
- putc(c, fpOut);
-
- Well, as I said I agree with Larry's second point. I don't expect everyone
- to agree with what I've said above. I would be interested to hear what
- other people think about ways to apply style rules to make Perl and other
- kinds of source code easier to read.
- --
- Todd Ogasawara, U. of Hawaii, Psychology Department
- BITNET: todd@uhunix
- INTERNET: todd@uhunix.UHCC.HAWAII.EDU
-