home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 16171 < prev    next >
Encoding:
Text File  |  1992-11-12  |  1.6 KB  |  44 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!darwin.sura.net!convex!news.utdallas.edu!corpgate!bnrgate!bnr.co.uk!pipex!warwick!bham!bhamvx!mccauleyba
  3. From: mccauleyba@vax1.bham.ac.uk (Brian McCauley)
  4. Subject: Re: Bad 'for' statement?
  5. Sender: usenet@rs6000.bham.ac.uk (USENET News Service)
  6. Message-ID: <1992Nov12.185453.1@vax1.bham.ac.uk>
  7. Date: Thu, 12 Nov 1992 18:54:53 GMT
  8. Lines: 32
  9. References: <1992Nov12.160420.18097@rs6000.bham.ac.uk>
  10. Organization: University of Birmingham
  11.  
  12. In article <1992Nov12.160420.18097@rs6000.bham.ac.uk>, pickerig@eee.bham.ac.uk (Mr. G. Pickering) writes:
  13. > Could you tell me if this is really a syntax error as AT&T 2.1 reports?
  14. >   for(int i=0, int j=10;   i<10;   i++, j++)
  15. >   {
  16. >     // do something
  17. >   }
  18. Yes. I don't have the actual syntax tables to hand but what they say can be
  19. sumarised as follows:
  20.  
  21. The comma operator joins 2 expressions into one expression by discarding the
  22. value of the first.
  23.  
  24. A statement can be either an expression followed my a semicolon _or_ a
  25. definition (amongst other things).
  26.  
  27. A definition is not an expression so you can't say
  28. `a=4+(int t=5);'
  29. nor can you say
  30. `int i=0, int j=10;'
  31.  
  32. You may be able to put forward an argument saying that an initialisation
  33. should be an expression returning a reference to the initialised object
  34. but I fear this could lead to gramatical ambiguities. 
  35. -- 
  36.     \\   ( )  NO BULLSHIT! from BAM (Brian McCauley)
  37.  .  _\\__[oo 
  38. .__/  \\ /\@  E-mail: B.A.McCauley@bham.ac.uk
  39. .  l___\\        Fax: +44 21 625 2175
  40.  # ll  l\\     Snail: 197 Harborne Lane, Birmingham, B29 6SS, UK
  41. ###LL  LL\\     ICBM: 52.5N 1.9W
  42.  
  43.