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

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!usc!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!ux2.cso.uiuc.edu!ejk
  3. From: ejk@ux2.cso.uiuc.edu (Ed Kubaitis - CCSO)
  4. Subject: Re: coding style (was Re: Perl language formatting conventions?)
  5. References: <DAVE.92Aug25141544@pipi.iis.u-tokyo.ac.jp> <1992Aug25.214800.10825@netlabs.com> <1992Aug27.072110.24646@news.Hawaii.Edu> <1992Aug27.180029.19638@netlabs.com>
  6. Message-ID: <Btp60t.MLI@news.cso.uiuc.edu>
  7. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  8. Organization: University of Illinois - Urbana
  9. Date: Fri, 28 Aug 1992 14:10:05 GMT
  10. Lines: 51
  11.  
  12. lwall@netlabs.com (Larry Wall) writes:
  13.   |...
  14.   |I required curlies in Perl because people wrongly
  15.   |perceive this sort of thing:
  16.   |
  17.   |     while ( ( c = getc(fpIn) ) != EOF )
  18.   |         putc(c, fpOut);
  19.   |        count++;
  20.   |    printf("%d\n", count);
  21.   |
  22.  
  23. Alas, indentation is for people, not compilers. K&R (1st edition p 52): 
  24. "The indentation shows unequivocally what you want, but the compiler 
  25. does not get the message."  
  26.  
  27. When I was too new to the culture to know better, this quote inspired me
  28. to write a 2000+ line C application in a dialect of C that required no 
  29. braces (and no semi-colons.) These "tools of ignorance" for the compiler 
  30. were added by a 60-line shell/old-awk script during make. The script relied 
  31. on indentation, and a few restrictions on otherwise permissable C syntax. 
  32.  
  33. For me, it was a pleasant way to code, sort of like fishing in Alaska
  34. without mosquitoes. Indendation reflected control structure and the damn 
  35. braces were neither hiding at the end of the line nor stealing valuable 
  36. real estate on my miserly 24-line ascii terminal.
  37.  
  38.   |This is also why I prefer outdenting the trailing curly.  If you say,
  39.   |as some do for reasons that they have recently admitted are related
  40.   |to cultural continuity,
  41.   |
  42.   |     while ( ( c = getc(fpIn) ) != EOF ) {
  43.   |         putc(c, fpOut);
  44.   |        count++;
  45.   |        }
  46.   |    printf("%d\n", count);
  47.   |
  48.   |then you're actually trying to ignore the existence of the trailing curly,
  49.   |and relying on the indentation for grouping.  Why else would you line
  50.   |it up except to make it more or less invisible?  
  51.  
  52. Exactly! Block delimiters are for compilers, not people. My experiment in 
  53. indent-structured C suggested (to me at least) that braces in a rigorously 
  54. indented program carry little information. So I do want to make braces more 
  55. or less invisible so as not to visually distract from the important 
  56. information provided by the indentation. (Hiding the trailing brace on the 
  57. end of the last line of the block makes adding new lines and visually 
  58. syntax-checking nested structures more difficult, so I don't go that far.)
  59.  
  60. ----------------------------------
  61. Ed Kubaitis (ejk@ux2.cso.uiuc.edu)
  62. Computing & Communications Services Office - University of Illinois, Urbana
  63.