home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!usc!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!ux2.cso.uiuc.edu!ejk
- From: ejk@ux2.cso.uiuc.edu (Ed Kubaitis - CCSO)
- Subject: Re: coding style (was Re: Perl language formatting conventions?)
- 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>
- Message-ID: <Btp60t.MLI@news.cso.uiuc.edu>
- Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
- Organization: University of Illinois - Urbana
- Date: Fri, 28 Aug 1992 14:10:05 GMT
- Lines: 51
-
- lwall@netlabs.com (Larry Wall) writes:
- |...
- |I required curlies in Perl because people wrongly
- |perceive this sort of thing:
- |
- | while ( ( c = getc(fpIn) ) != EOF )
- | putc(c, fpOut);
- | count++;
- | printf("%d\n", count);
- |
-
- Alas, indentation is for people, not compilers. K&R (1st edition p 52):
- "The indentation shows unequivocally what you want, but the compiler
- does not get the message."
-
- When I was too new to the culture to know better, this quote inspired me
- to write a 2000+ line C application in a dialect of C that required no
- braces (and no semi-colons.) These "tools of ignorance" for the compiler
- were added by a 60-line shell/old-awk script during make. The script relied
- on indentation, and a few restrictions on otherwise permissable C syntax.
-
- For me, it was a pleasant way to code, sort of like fishing in Alaska
- without mosquitoes. Indendation reflected control structure and the damn
- braces were neither hiding at the end of the line nor stealing valuable
- real estate on my miserly 24-line ascii terminal.
-
- |This is also why I prefer outdenting the trailing curly. If you say,
- |as some do for reasons that they have recently admitted are related
- |to cultural continuity,
- |
- | while ( ( c = getc(fpIn) ) != EOF ) {
- | putc(c, fpOut);
- | count++;
- | }
- | printf("%d\n", count);
- |
- |then you're actually trying to ignore the existence of the trailing curly,
- |and relying on the indentation for grouping. Why else would you line
- |it up except to make it more or less invisible?
-
- Exactly! Block delimiters are for compilers, not people. My experiment in
- indent-structured C suggested (to me at least) that braces in a rigorously
- indented program carry little information. So I do want to make braces more
- or less invisible so as not to visually distract from the important
- information provided by the indentation. (Hiding the trailing brace on the
- end of the last line of the block makes adding new lines and visually
- syntax-checking nested structures more difficult, so I don't go that far.)
-
- ----------------------------------
- Ed Kubaitis (ejk@ux2.cso.uiuc.edu)
- Computing & Communications Services Office - University of Illinois, Urbana
-