home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / perl / 5539 < prev    next >
Encoding:
Text File  |  1992-08-26  |  2.9 KB  |  70 lines

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