Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > Re: lcc first e...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 32 of 99 Topic 26092 of 26960
Post > Topic >>

Re: lcc first experience

by roberson@[EMAIL PROTECTED] (Walter Roberson) May 8, 2008 at 05:37 PM

In article
<cf0c2e4c-e25f-4ceb-a45d-5e056817552f@[EMAIL PROTECTED]
>,
Paul Hsieh  <websnarf@[EMAIL PROTECTED]
> wrote:

>C is an uncommon language in that it does not require a comparison
>operator in its if statements, and that all statements have side-
>effects. 

ANSI X3.159-1989  (aka C89)
Appendix A Language Syntax Summary

A.2.3 Statements

 (3.6) statement:
    labeled-statement
    compound-statement
    expression-statement
    selection-statement
    iteration-statement
    jump-statement

 (3.6.1) labeled-statement:
   identifier : statement
   case constant-expression : statement
   default : statement

In the first of those choices of 3.6.1, the identifier is a label.
Does a label have a side-effect? If not, then whether the first form
of labeled statement has a side effect depends upon whether the
statement on the right hand side -always- has a side effect, a point
which remains to be proved at this point in the analysis.

In the second of those choices of 3.6.1, does a constant-expression
have a side effect? If not, then whether the second form of labeled
statement has a side effect depends upon whether the statement
on the right hand side -always- has a side effect, a point which
remains to be proved at this point in the analysis.

In the third of these choices of 3.6.1, does the presence of 'default'
have a side effect? If not then etc..

  (3.6.2) compound-statement:
        {declaration-list$opt$ statement-list$opt$}

Please excuse my typographic mangling of the subscript 'opt' to $opt$.

Does the -absence- of a declaration-list always have a side-effect
in a compound-statement? If not then determining whether
compound-statements
always have side-effects, reduces down to determining whether
{statement-list$opt$} always has a side-effect. In such a statement,
does the -absence- of the statement-list always have a side-effect?
That is, is there a side-effect associated with the compound-statement
  {}
?? If not then we have identified a compound-statement with no side-
effect, and have thus identified a statement with no side-effect,
which in turn would allow us to substitute in {} for the 'statement'
****tion in all three choices of labeled-statement, so unless there
is a side-effect associated with the presence of a label or
constant-expression or 'default' label, labeled-statements need not
have any side-effects.

Similarily, expression-statement (3.6.3) is  expression$opt$
and by simply exercising our option to not put in an expression,
we appear to have found another form of statement that has no
side-effects.

If we examine section 3.6.3 of C89 properr, we find that it is entitled

  3.6.3 Expression and Null Statements
and contains a paragraph:

  A null statement (consisting of just a semicolon) performs no
operations.

Personally, I find it difficult to see how there could be a "side-effect"
associated with a statement that the C89 standard *specifically*
says "performs no operations", but perhaps I'm just funny that way.


We can continue this analysis through selection-statement and
interation-statement and find several forms of each of those which have 
no side-effects.


This brings us to (3.6.6) jump-statement
  goto identifier ;
  continue ;
  break ;
  return expression$opt$ ;

At this point there is room for disagreement over what constitutes a
'side-effect'. If a 'continue;' appears as the terminal statement
inside a loop, then has it had a side-effect or not, considering the
action would be the same if it was not there.  If a 'break' appears as
the terminal statement of a loop which does not have post-statements
with side-effects (e.g., the third part of the for() is empty or has no
side effects) and which would not have executed any more interations
anyhow, then is it a side-effect? If a goto statement branches to the
next line, has it had a side-effect? If a return statement with no
expression appears as the last line of a void function, then
does that return have a side-effect?

I would be prepared to accept for the purposes of discussion
a definition that indicated that a jump-statement always has a
side-effect. But jump-statement is only one of the seven forms
of C89 statements and the other six all have valid (and sometimes useful)
forms that have no side-effects.

I must therefore disagree with the claim that,

>all statements have side-
>effects. 

as there are numerous C statements possible that have no side-
effects.
-- 
   "I was very young in those days, but I was also rather dim."
   -- Christopher Priest
 




 99 Posts in Topic:
[OT] lcc first experience
Morris Dovey <mrdovey@  2008-05-06 12:33:06 
Re: lcc first experience
=?ISO-8859-1?Q?Tom=E1s_=D  2008-05-06 10:41:28 
Re: lcc first experience
Morris Dovey <mrdovey@  2008-05-06 13:02:55 
Re: lcc first experience
Johannes Bauer <dfnson  2008-05-06 20:51:07 
Re: lcc first experience
=?ISO-8859-1?Q?Tom=E1s_=D  2008-05-06 15:35:32 
Re: lcc first experience
Antoninus Twink <nospa  2008-05-06 20:10:35 
Re: lcc first experience
Morris Dovey <mrdovey@  2008-05-06 13:21:40 
Re: [OT] lcc first experience
Keith Thompson <kst-u@  2008-05-06 11:19:10 
Re: lcc first experience
=?ISO-8859-1?Q?Tom=E1s_=D  2008-05-06 11:47:38 
Re: [OT] lcc first experience
Morris Dovey <mrdovey@  2008-05-06 13:49:09 
Re: lcc first experience
Paul Hsieh <websnarf@[  2008-05-07 10:52:56 
Re: lcc first experience
Eric Sosman <Eric.Sosm  2008-05-07 13:58:53 
Re: lcc first experience
dj3vande@[EMAIL PROTECTED  2008-05-07 18:41:15 
Re: lcc first experience
Spiros Bousbouras <spi  2008-05-08 11:20:03 
Re: lcc first experience
muntyan@[EMAIL PROTECTED]  2008-05-08 12:49:22 
Re: lcc first experience
roberson@[EMAIL PROTECTED  2008-05-08 20:11:47 
Re: lcc first experience
muntyan@[EMAIL PROTECTED]  2008-05-08 19:31:19 
Re: lcc first experience
Richard Heathfield <rj  2008-05-09 05:25:35 
Re: lcc first experience
jacob navia <jacob@[EM  2008-05-09 08:44:45 
Re: lcc first experience
Richard Heathfield <rj  2008-05-09 07:35:23 
Re: lcc first experience
roberson@[EMAIL PROTECTED  2008-05-09 14:59:38 
Re: lcc first experience
Nick Keighley <nick_ke  2008-05-09 01:48:41 
Re: lcc first experience
Spiros Bousbouras <spi  2008-05-08 16:17:14 
Re: lcc first experience
richard@[EMAIL PROTECTED]  2008-05-08 23:45:58 
Re: lcc first experience
Nick Keighley <nick_ke  2008-05-09 01:50:59 
Re: lcc first experience
richard@[EMAIL PROTECTED]  2008-05-09 12:00:03 
Re: lcc first experience
CBFalconer <cbfalconer  2008-05-07 17:48:52 
Re: lcc first experience
cri@[EMAIL PROTECTED] (R  2008-05-08 02:30:57 
Re: lcc first experience
CBFalconer <cbfalconer  2008-05-08 13:40:41 
Re: lcc first experience
cri@[EMAIL PROTECTED] (R  2008-05-10 04:39:47 
Re: lcc first experience
Paul Hsieh <websnarf@[  2008-05-08 09:55:08 
Re: lcc first experience
roberson@[EMAIL PROTECTED  2008-05-08 17:37:05 
Re: lcc first experience
jacob navia <jacob@[EM  2008-05-08 19:42:31 
Re: lcc first experience
roberson@[EMAIL PROTECTED  2008-05-08 18:28:31 
Re: lcc first experience
Keith Thompson <kst-u@  2008-05-08 11:55:57 
Re: lcc first experience
muntyan@[EMAIL PROTECTED]  2008-05-08 15:13:58 
Re: lcc first experience
roberson@[EMAIL PROTECTED  2008-05-09 02:07:23 
Re: lcc first experience
Paul Hsieh <websnarf@[  2008-05-08 13:24:45 
Re: lcc first experience
Eric Sosman <Eric.Sosm  2008-05-08 17:20:45 
Re: lcc first experience
jacob navia <jacob@[EM  2008-05-09 07:43:41 
Re: lcc first experience
Richard Heathfield <rj  2008-05-09 05:54:58 
Re: lcc first experience
roberson@[EMAIL PROTECTED  2008-05-09 03:31:44 
Re: lcc first experience
richard@[EMAIL PROTECTED]  2008-05-08 21:02:02 
Re: lcc first experience
richard@[EMAIL PROTECTED]  2008-05-08 21:08:29 
Re: lcc first experience
Keith Thompson <kst-u@  2008-05-08 15:15:32 
Re: lcc first experience
CBFalconer <cbfalconer  2008-05-08 19:04:25 
Re: lcc first experience
Keith Thompson <kst-u@  2008-05-08 22:40:25 
Re: lcc first experience
vippstar@[EMAIL PROTECTED  2008-05-08 14:44:50 
Re: lcc first experience
Spiros Bousbouras <spi  2008-05-08 16:09:33 
Re: lcc first experience
Eric Sosman <esosman@[  2008-05-08 21:14:14 
Re: lcc first experience
Nick Keighley <nick_ke  2008-05-09 01:19:55 
Re: [OT] lcc first experience
jacob navia <jacob@[EM  2008-05-06 20:26:59 
Re: [OT] lcc first experience
"Malcolm McLean"  2008-05-06 21:48:31 
Re: [OT] lcc first experience
nembo kid <user@[EMAIL  2008-05-07 17:51:45 
Re: [OT] lcc first experience
roberson@[EMAIL PROTECTED  2008-05-07 16:03:30 
Re: lcc first experience
vippstar@[EMAIL PROTECTED  2008-05-07 09:24:27 
Re: [OT] lcc first experience
Morris Dovey <mrdovey@  2008-05-07 12:06:24 
Re: [OT] lcc first experience
Joe Wright <joewwright  2008-05-07 16:28:29 
Re: lcc first experience
Bart <bc@[EMAIL PROTEC  2008-05-07 13:59:16 
Re: lcc first experience
jacob navia <jacob@[EM  2008-05-08 00:55:56 
Re: lcc first experience
Eric Sosman <esosman@[  2008-05-07 20:32:37 
Re: lcc first experience
Keith Thompson <kst-u@  2008-05-07 18:26:14 
binary literals (was Re: lcc first experience)
Chris Torek <nospam@[E  2008-05-08 02:18:14 
Re: lcc first experience
"Dik T. Winter"  2008-05-08 10:12:38 
Re: lcc first experience
richard@[EMAIL PROTECTED]  2008-05-08 10:36:25 
Re: lcc first experience
CBFalconer <cbfalconer  2008-05-07 20:26:31 
Re: binary literals (was Re: lcc first experience)
Ben Bacarisse <ben.use  2008-05-08 12:14:32 
Re: [OT] lcc first experience
rlb@[EMAIL PROTECTED] (R  2008-05-08 06:29:24 
Re: [OT] lcc first experience
CBFalconer <cbfalconer  2008-05-08 13:45:24 
Re: [OT] lcc first experience
rlb@[EMAIL PROTECTED] (R  2008-05-16 10:37:27 
Re: lcc first experience
Spiros Bousbouras <spi  2008-05-09 11:42:36 
Re: lcc first experience
Spiros Bousbouras <spi  2008-05-09 11:53:06 
Re: lcc first experience
Old Wolf <oldwolf@[EMA  2008-05-11 16:03:04 
Re: lcc first experience
Antoninus Twink <nospa  2008-05-09 11:42:57 
Re: [OT] lcc first experience
Harald van =?UTF-8?b?RMSz  2008-05-09 18:34:51 
Re: [OT] lcc first experience
jacob navia <jacob@[EM  2008-05-09 19:23:54 
Re: [OT] lcc first experience
Morris Dovey <mrdovey@  2008-05-09 12:29:04 
Re: [OT] lcc first experience
jacob navia <jacob@[EM  2008-05-09 20:03:18 
Re: [OT] lcc first experience
Morris Dovey <mrdovey@  2008-05-09 13:58:26 
Re: [OT] lcc first experience
rlb@[EMAIL PROTECTED] (R  2008-05-16 10:38:37 
Re: [OT] lcc first experience
Eric Sosman <esosman@[  2008-05-09 13:39:04 
Re: [OT] lcc first experience
jacob navia <jacob@[EM  2008-05-09 19:59:38 
Re: [OT] lcc first experience
Eric Sosman <esosman@[  2008-05-09 17:10:52 
Re: [OT] lcc first experience
Eric Sosman <esosman@[  2008-05-10 17:04:50 
Re: [OT] lcc first experience
Richard Heathfield <rj  2008-05-09 17:51:42 
Re: [OT] lcc first experience
jacob navia <jacob@[EM  2008-05-09 19:56:19 
Re: [OT] lcc first experience
Flash Gordon <spam@[EM  2008-05-09 19:33:22 
Re: [OT] lcc first experience
Keith Thompson <kst-u@  2008-05-09 13:03:38 
Re: [OT] lcc first experience
Flash Gordon <spam@[EM  2008-05-09 18:27:59 
Re: [OT] lcc first experience
Harald van =?UTF-8?b?RMSz  2008-05-09 20:25:29 
Re: lcc first experience
Harald van =?UTF-8?b?RMSz  2008-05-09 20:52:51 
Re: lcc first experience
Antoninus Twink <nospa  2008-05-09 20:55:58 
Re: lcc first experience
"Malcolm McLean"  2008-05-11 10:09:21 
Re: lcc first experience
Harald van =?UTF-8?b?RMSz  2008-05-09 21:06:34 
Re: [OT] lcc first experience
CBFalconer <cbfalconer  2008-05-09 16:53:05 
Re: [OT] lcc first experience
Antoninus Twink <nospa  2008-05-09 23:41:13 
Re: [OT] lcc first experience
Harald van =?UTF-8?b?RMSz  2008-05-09 23:50:09 
Re: [OT] lcc first experience
Ben Bacarisse <ben.use  2008-05-10 03:28:11 
Re: [OT] lcc first experience
Antoninus Twink <nospa  2008-05-10 23:32:59 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 16:40:37 CDT 2008.