home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / volume.23 / text0068.txt < prev    next >
Encoding:
Text File  |  1991-06-15  |  2.6 KB  |  64 lines

  1. Submitted-by: arnold%audiofax.com@mathcs.emory.edu (Arnold Robbins)
  2.  
  3. >In article <1991May14.185737.15746@uunet.uu.net> arnold@audiofax.com writes:
  4. >> One of the things that happened when new awk was first realeased was a lot
  5. >> of cleaning up and consistencizing (if I may coin a term) of the awk 
  6. >> language.
  7.  
  8. In article <1991May15.165824.6896@uunet.uu.net> peter@ficc.ferranti.com (Peter da Silva) writes:
  9. >I don't see how that makes things any more consistent. If you look at the
  10. >grammer there's no ambiguity that needs to be resolved by adding that
  11. >semicolon. Does anyone have an idea what the reasoning behind this was?
  12. >To me, it adds confusion by treating a block as a statement.
  13.  
  14. This is getting off the topic of standards, but what the heck.  You
  15. ommitted my rationalization of the consistency.  To rephrase: statements
  16. at the rule level should be consistent with statements inside an action.
  17. Statements in a action are separated by newline or semi-colon, therefore
  18. rules (patterns plus actions) should also be separated by newlines or
  19. semi-colons.  It is illegal to type
  20.  
  21.     { i = 1  j = 2 }
  22.  
  23. in an action without the semicolon or newline between the assignments.
  24. Therefore it "should" be illegal to type rules without the separator.
  25. (So yes, block are statements.  This makes sense, since they're executed
  26. in the order they occur in the program.)
  27.  
  28. As I also mentioned, modern implemenations of 'nawk' (V.4 nawk, gawk)
  29. accept rules with or without the semicolon, so it doesn't really matter.
  30. (Many C compilers continue to accept `i =+ 1' but that doesn't make it
  31. good programming practice...)
  32.  
  33. >Oh, and my V.3.2 system has no problem with that:
  34. >
  35. >% ls -l | awk 'NF==9 { h[$3] += $5 } END {for(i in h) print i,h[i]}'
  36. >root 7985
  37. >peter 731662
  38.  
  39. You typed "awk", no 'n'.  My example used "nawk", with an 'n'.    Try
  40.  
  41.     awk 'BEGIN { foo() }
  42.         function foo () { print "hi" }'
  43.  
  44. on your V.3.2 system and watch "awk" (no 'n') barf all over your screen.
  45. We're talking two very different animals here.
  46.  
  47. For whatever it's worth, the V.3.2 nawk man page said that in the "next
  48. major release" nawk would become 'awk' and old awk would become 'oawk'.
  49. This doesn't seem to have happened in V.4.  It probably never will in
  50. System V.  4.4BSD will most likely ship gawk for it's version of awk.
  51.  
  52. Next topic, please?
  53. -- 
  54. Arnold Robbins                 AudioFAX, Inc. | Threads are the
  55. 2000 Powers Ferry Road, Suite 200 / Marietta, GA. 30067 | lack of an idea.
  56. INTERNET: arnold@audiofax.com  Phone:   +1 404 618 4281 |     -- Rob Pike
  57. UUCP:      emory!audfax!arnold  Fax-box: +1 404 618 4581 |
  58.  
  59. [ He's right.  I've cross-posted this to comp.unix.questions, with
  60.   followup's directed there. -- mod ]
  61.  
  62. Volume-Number: Volume 23, Number 72
  63.  
  64.