Topic: for(a;b;c;d)?


Author: dick@silicon.csci.csusb.edu (Dr. Richard Botting)
Date: 1995/10/15
Raw View
I was sketching an example for class and wrote
 for( Digit* p=d, *q=d+1
and suddenly didn't know if this declared 'q' or not.  I was used to
 for( i=0, j=0, k=N;....
and like the new improved
 for( int i=0, j=0, k=N; ...
form.  But started to worry about ambiguities.

This lead me into my 1990 ARM and pages 88,89,397,393,and 410.  And from
there to a fast scan of the comp.lan.c++ FAQ.

If I read it right then the following are all valid:
Form Syntax    My Reaction
(A): for(e; e; e)S   //No problem
(B): for(d; e; e)S   //Neat idea
(C): for(d; e; e; e)S  //Personal parse error, but neat if OK
(D): for(e; e; e; e)S  //Personal parse error, and why?
where
 e is an expression,
and S is any statement,
and d is any declaration with its semicolon removed.

I was wondering whether the standard will be permitting all the above
and also what kind of discussions and examples might be
on record.

By the way, I tried
  for(int i=1; i++; 0; i++)
        ;
on our local (older rs6000-ibm-aix32/2.4.5 ) Gnu CC and it was
rejected(parse error before `;').  But compilation does not a standard make.

Also, by the way, I don't mind whether for(;;;) is standard or not, as long
as I know one way or the other.

--
 dick@csci.csusb.edu=rbotting@wiley.csusb.edu.
Find out what's new at http://www.csci.csusb.edu/doc/www.sites.html
Disclaimer:`CSUSB may or may not agree with this message`.
Copyright(1995):Copy this freely but include the following link to the
<a href="http://www.csci.csusb.edu/dick/signature.html">author's signature</a>
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]





Author: dick@silicon.csci.csusb.edu (Dr. Richard Botting)
Date: 1995/10/17
Raw View
Dr. Richard Botting (dick@silicon.csci.csusb.edu) wrote:
[snip]
: This lead me into my 1990 ARM and pages 88,89,397,393,and 410.  And from
: there to a fast scan of the comp.lan.c++ FAQ.

: If I read it right then the following are all valid:
: Form Syntax    My Reaction
: (A): for(e; e; e)S   //No problem
: (B): for(d; e; e)S   //Neat idea
: (C): for(d; e; e; e)S  //Personal parse error, but neat if OK
: (D): for(e; e; e; e)S  //Personal parse error, and why?
: where
:  e is an expression,
: and S is any statement,
: and d is any declaration with its semicolon removed.

: I was wondering whether the standard will be permitting all the above
: and also what kind of discussions and examples might be
: on record.

In the HTML version of the Draft ANSI/ISO standard options (C) and (D)
no longer exist:
  iteration-statement:
   while ( condition ) statement
   do statement  while ( expression ) ;
   for ( for-init-statement conditionopt ; expressionopt ) statement
  for-init-statement:
   expression-statement
   simple-declaration


(I managed to get in and get the wphtml.tar.gz file and unpack it this
 morning.
)

--
 dick@csci.csusb.edu=rbotting@wiley.csusb.edu.
Find out what's new at http://www.csci.csusb.edu/doc/www.sites.html
Disclaimer:`CSUSB may or may not agree with this message`.
Copyright(1995):Copy this freely but include the following link to the
<a href="http://www.csci.csusb.edu/dick/signature.html">author's signature</a>
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]