home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- 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
- From: mccauleyba@vax1.bham.ac.uk (Brian McCauley)
- Subject: Re: Bad 'for' statement?
- Sender: usenet@rs6000.bham.ac.uk (USENET News Service)
- Message-ID: <1992Nov12.185453.1@vax1.bham.ac.uk>
- Date: Thu, 12 Nov 1992 18:54:53 GMT
- Lines: 32
- References: <1992Nov12.160420.18097@rs6000.bham.ac.uk>
- Organization: University of Birmingham
-
- In article <1992Nov12.160420.18097@rs6000.bham.ac.uk>, pickerig@eee.bham.ac.uk (Mr. G. Pickering) writes:
- > Could you tell me if this is really a syntax error as AT&T 2.1 reports?
- >
- > for(int i=0, int j=10; i<10; i++, j++)
- > {
- > // do something
- > }
- Yes. I don't have the actual syntax tables to hand but what they say can be
- sumarised as follows:
-
- The comma operator joins 2 expressions into one expression by discarding the
- value of the first.
-
- A statement can be either an expression followed my a semicolon _or_ a
- definition (amongst other things).
-
- A definition is not an expression so you can't say
- `a=4+(int t=5);'
- nor can you say
- `int i=0, int j=10;'
-
- You may be able to put forward an argument saying that an initialisation
- should be an expression returning a reference to the initialised object
- but I fear this could lead to gramatical ambiguities.
- --
- \\ ( ) NO BULLSHIT! from BAM (Brian McCauley)
- . _\\__[oo
- .__/ \\ /\@ E-mail: B.A.McCauley@bham.ac.uk
- . l___\\ Fax: +44 21 625 2175
- # ll l\\ Snail: 197 Harborne Lane, Birmingham, B29 6SS, UK
- ###LL LL\\ ICBM: 52.5N 1.9W
-
-