473,394 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

role of semicolon

#include <stdio.h>
int main(void)
{
int i = 0;
++ i; ++ i;
printf("i equals %d\n", i);
return 0;
}

I've been trying to determine the great and manifold uses of the semicolon
in c. It's not such an easy thing. Q1) Is the above prog conforming? My
compiler likes it just fine. Q2) If so, how many statements are in main?
MPJ
Nov 14 '05 #1
64 3293
"Merrill & Michele" <be********@comcast.net> wrote in message
news:lL********************@comcast.com...
#include <stdio.h>
int main(void)
{
int i = 0;
++ i; ++ i;
printf("i equals %d\n", i);
return 0;
}

I've been trying to determine the great and manifold uses of the
semicolon in c. It's not such an easy thing. Q1) Is the above prog
conforming? My compiler likes it just fine.
Yes.
Q2) If so, how many statements are in main?


In terms of the language grammar, there are four statements inside main: the
two pre-increments and the call to printf() (which are all
expression-statements), plus the return (which is a jump-statement). "int i
= 0;" is a declaration, not a statement, despite the fact that code will
normally be generated due to the presence of an initialiser.

Part of the definition of main is the compound-statement, from the '{' to
the '}' inclusive. A compound-statement is a statement, so if you count that
too, then the answer is five.

Again according to the language grammar, uses of semi-colon seem to be:
- terminating declarations,
- terminating expression-statements (expression statements may consist of
only the terminating ';'),
- terminating do..while loops (a type of iteration-statement),
- seperating the three expressions at the top of a for loop (another type
of iteration-statement), and
- terminating jump-statements (goto, continue, break, return).

Open to correction...

Alex
Nov 14 '05 #2

"Alex Fraser" <me@privacy.net> wrote in message
news:32*************@individual.net...
"Merrill & Michele" <be********@comcast.net> wrote in message
news:lL********************@comcast.com...
#include <stdio.h>
int main(void)
{
int i = 0;
++ i; ++ i;
printf("i equals %d\n", i);
return 0;
}

I've been trying to determine the great and manifold uses of the
semicolon in c. It's not such an easy thing. Q1) Is the above prog
conforming? My compiler likes it just fine.
Yes.
Q2) If so, how many statements are in main?


In terms of the language grammar, there are four statements inside main:

the two pre-increments and the call to printf() (which are all
expression-statements), plus the return (which is a jump-statement). "int i = 0;" is a declaration, not a statement, despite the fact that code will
normally be generated due to the presence of an initialiser.

Part of the definition of main is the compound-statement, from the '{' to
the '}' inclusive. A compound-statement is a statement, so if you count that too, then the answer is five.

Again according to the language grammar, uses of semi-colon seem to be:
- terminating declarations,
- terminating expression-statements (expression statements may consist of
only the terminating ';'),
- terminating do..while loops (a type of iteration-statement),
- seperating the three expressions at the top of a for loop (another type
of iteration-statement), and
- terminating jump-statements (goto, continue, break, return).

Open to correction...


Thank you for the generous detail. The only germane correction I saw is
that semicolon is spelled without a hyphen. MPJ
Nov 14 '05 #3
On Fri, 17 Dec 2004 14:37:53 +0000, Alex Fraser wrote:

....
Part of the definition of main is the compound-statement, from the '{' to
the '}' inclusive. A compound-statement is a statement, so if you count that
too, then the answer is five.


Interestingly this is an example (and the only one) of when a compound
statement ISN'T a statement. Check the grammar.

Lawrence

Nov 14 '05 #4
"Lawrence Kirby"
Alex Fraser wrote: Part of the definition of main is the compound-statement, from the '{' to the '}' inclusive. A compound-statement is a statement, so if you count that too, then the answer is five.


Interestingly this is an example (and the only one) of when a compound
statement ISN'T a statement. Check the grammar.


[uses cordless keyboard+mouse for 1st time and wonders how he endured life
before]

I believe Mr. Kirby refers to a statement such as:
i = 6; ++j;
and calls this a compound statement. I can speculate on how many statements
it is and know that I could get it right if I got two swings at the pitch.
I will drag this forum wildly OT if I start into English grammar and its
inability to express truth about number, so which is it? MPJ
Nov 14 '05 #5

"Merrill & Michele" <be********@comcast.net> wrote in message
news:lL********************@comcast.com...
#include <stdio.h>
int main(void)
{
int i = 0;
++ i; ++ i;
printf("i equals %d\n", i);
return 0;
}

I've been trying to determine the great and manifold uses of the semicolon
in c.
There's only *one* use. To terminate a statement.
It's not such an easy thing.
Sure it is. It's a syntactical element that has only
one meaning, unlike some others whose meaning depends
upon context (e.g. the '&' character).
Q1) Is the above prog conforming?
Yes.
My
compiler likes it just fine. Q2) If so, how many statements are in main?


Five.

-Mike
Nov 14 '05 #6
"Alex Fraser" <me@privacy.net> wrote in message
news:32*************@individual.net...
"Merrill & Michele" <be********@comcast.net> wrote in message
news:lL********************@comcast.com...
#include <stdio.h>
int main(void)
{
int i = 0;
++ i; ++ i;
printf("i equals %d\n", i);
return 0;
}

I've been trying to determine the great and manifold uses of the
semicolon in c. It's not such an easy thing. Q1) Is the above prog
conforming? My compiler likes it just fine.
Yes.
Q2) If so, how many statements are in main?


In terms of the language grammar, there are four statements inside main:

the two pre-increments and the call to printf() (which are all
expression-statements), plus the return (which is a jump-statement). "int i = 0;" is a declaration, not a statement,
A declaration is a statement.

despite the fact that code will
normally be generated due to the presence of an initialiser.

Part of the definition of main is the compound-statement, from the '{' to
the '}' inclusive.
Ah, I forgot about that.
A compound-statement is a statement, so if you count that
too, then the answer is five.


Then my answer would be six. :-)

-Mike
Nov 14 '05 #7

"Merrill & Michele" <be********@comcast.net> wrote in message
news:OL********************@comcast.com...
"Lawrence Kirby"
Alex Fraser wrote: Part of the definition of main is the compound-statement, from the '{' to the '}' inclusive. A compound-statement is a statement, so if you
count
that too, then the answer is five.
Interestingly this is an example (and the only one) of when a compound
statement ISN'T a statement. Check the grammar.


[uses cordless keyboard+mouse for 1st time and wonders how he endured life
before]

I believe Mr. Kirby refers to a statement such as:


I'm absolutely sure what he's referring to, but
I think he means that the { and } which delimit
a function body do not comprise a 'compound statement'.
(So I believe my 'didn't think of that' remark elsethread should
be retracted. :-))
i = 6; ++j;
and calls this a compound statement.
No, those are *two* statements (on one line).
AFAIK, a 'compound statement' begins with { and
ends with } (but a function body does not qualify
if I understand Mr. Kirby.)
I can speculate on how many statements
it is and know that I could get it right if I got two swings at the pitch.
Most batters get three. :-)
I will drag this forum wildly OT if I start into English grammar and its
inability to express truth about number, so which is it? MPJ


Two. Or to. Or too. Take your pick. :-)

-Mike
Nov 14 '05 #8
"Merrill & Michele" <be********@comcast.net> writes:
Lawrence Kirby" writes:
Alex Fraser wrote:
> Part of the definition of main is the compound-statement, from
> the '{' to the '}' inclusive. A compound-statement is a
> statement, so if you count that too, then the answer is five.
Interestingly this is an example (and the only one) of when a compound
statement ISN'T a statement. Check the grammar.

[snip]
I believe Mr. Kirby refers to a statement such as:
i = 6; ++j;
and calls this a compound statement. I can speculate on how many statements
it is and know that I could get it right if I got two swings at the pitch.
I will drag this forum wildly OT if I start into English grammar and its
inability to express truth about number, so which is it? MPJ


(Malformed attribution lines for Lawrence Kirby and Alex Fraser fixed.
"Merrill & Michele", whatever you're doing that creates this problem,
*please* stop doing it. I've noticed that some of your posts have
this problem and some don't. If there are actually two different
people posting from your account, the one who gets this right should
educate the other one.)

No, he's not referring to "i = 6; ++j;". That's not a compound
statement, it's just two statements on one line. It should be clear
from the context that he's referring to the compound-statement from
the '{' to the '}' inclusive.

In most contexts in C source, an end-of-line is just like any other
whitespace. (String literals and macro definitions are the major
exceptions.) There's no grammatical significance to the fact that
both statements are on one line.

If you look at the C grammar, a "compound-statement" consists of a
'{' delimiter, followed by a sequence of zero or more declarations or
statements, followed by a '}' delimiter. (In C90, declarations must
precede statements; in C99, they can be mixed.) The line "i = 6; ++j;"
is not a compound statement because it's not surrounded by '{' and '}'
delimiters.

In general, a compound-statement can appear wherever a statement can
appear. In addition, a compound-statement appears as part of a
function-definition; in that context, according to the grammar, the
compound-statement is not a statement.

The grammar for a function-definition is:

function-definition:
declaration-specifiers declarator declaration-list(opt) compound-statement

(the optional declaration-list is for an old-style non-prototyped
definition). This is the only place in the grammar that allows
(actually requires) a compound-statement without allowing any other
kind of statement.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #9
"Mike Wahler" <mk******@mkwahler.net> writes:
[...]
A declaration is a statement.


No, it isn't, according to the grammar in the standard. A "statement"
can be any of the following:

labeled-statement
compound-statement
expression-statement
selection-statement
iteration-statement
jump-statement

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #10
"Mike Wahler" <mk******@mkwahler.net> writes:
[...]
I'm absolutely sure what he's referring to, but
I think he means that the { and } which delimit
a function body do not comprise a 'compound statement'.
(So I believe my 'didn't think of that' remark elsethread should
be retracted. :-))


Actually, according to the grammar, it is a "compound-statement", but
it's not a "statement".

A "function-definition" consists of:

declaration-specifiers declarator declaration-list(opt) compound-statement

This is the only occurrence of "compound-statement" in the grammar
that's not a "statement".

Note that if the grammar required a "statement" here rather than a
"compound-statement", the following would be legal:

int foo(void)
return 42; /* not legal C */

Instead, we have to write:

int foo(void)
{
return 42;
}

The claim that this "compound-statement" is not a "statement" is based
on a painfully literal reading of the grammar. If you want to argue
that a compound statement must be a statement (by the rules of
ordinary English grammar), I won't disagree too strongly.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #11

"Keith Thompson" <ks***@mib.org> wrote in message
news:ln************@nuthaus.mib.org...
"Mike Wahler" <mk******@mkwahler.net> writes:
[...]
A declaration is a statement.


No, it isn't, according to the grammar in the standard. A "statement"
can be any of the following:

labeled-statement
compound-statement
expression-statement
selection-statement
iteration-statement
jump-statement


I stand corrected.

-Mike
Nov 14 '05 #12
Keith Thompson wrote:
Mike Wahler writes:
[...]
A declaration is a statement.

No, it isn't, according to the grammar in the standard.
A "statement" can be any of the following:

labeled-statement
compound-statement
expression-statement
selection-statement
iteration-statement
jump-statement


Honestly Keith,

You remind me of Beetle Bailey's friend Zero.
You take the statements in the standard
just a little too literally.

According to
the American Heritage Dictionary of the English language

http://www.bartleby.com/61/

"declaration
1. An explicit, formal announcement, either oral or written.
2. The act or process of declaring.
3. A statement of taxable goods or of properties subject to duty.
4. Law
a. A formal statement by a plaintiff
specifying the facts and circumstances
constituting his or her cause of action.
b. An unsworn statement of facts that is admissible as evidence.
5. Games A bid,
especially the final bid of a hand in certain card games."
Nov 14 '05 #13
In article <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:
The claim that this "compound-statement" is not a "statement" is based
on a painfully literal reading of the grammar.


Depends on which way you wish to go in the grammar. A compound-statement
is a specific form of a statement (and has been so since the introduction
of the term in Algol 60). So, by all means, the function body is a
statement of particular form (and that was not the case in Algol 60).
In my opinion when Lawrence wrote that that particular compound-statement
was not a statement, he was wrong.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Nov 14 '05 #14

"Mike Wahler"
"Merrill & Michele"
#include <stdio.h>
int main(void)
{
int i = 0;
++ i; ++ i;
printf("i equals %d\n", i);
return 0;
}

I've been trying to determine the great and manifold uses of the semicolon in c.
There's only *one* use. To terminate a statement.
It's not such an easy thing.


Sure it is. It's a syntactical element that has only
one meaning, unlike some others whose meaning depends
upon context (e.g. the '&' character).
Q1) Is the above prog conforming?


Yes.
My
compiler likes it just fine. Q2) If so, how many statements are in

main?
Five.


Along the same lines, the following code compiles for me:

static int doNothing1(void)
{
return 0;
}
int main(void)
{
int a = 0;
int b = 0;
int c = 0;
int d = 0;
int e = 0;
void doNothing2(void);

doNothing1();
doNothing2();

return 0;
}

void doNothing2(void)
{
}

Q1) Does this prog conform?
Q2) If yes, then how many statements are in each of the 3 functions?
[OT to Mr. Thompson] Q3) Are the attribution arrows correct? MPJ

Nov 14 '05 #15
Dik T. Winter wrote:
So, by all means, the function body is a
statement of particular form (and that was not the case in Algol 60).
In my opinion when Lawrence wrote that that particular
compound-statement was not a statement, he was wrong.


According to K&R2, A9.3 Compound Statement, page 222:
"The body of a function definition is a compound statement."

--
pete
Nov 14 '05 #16
pete wrote:

Dik T. Winter wrote:
So, by all means, the function body is a
statement of particular form
(and that was not the case in Algol 60).
In my opinion when Lawrence wrote that that particular
compound-statement was not a statement, he was wrong.


According to K&R2, A9.3 Compound Statement, page 222:
"The body of a function definition is a compound statement."


I don't think that what I posted
was relevant to what you were discussing. Sorry about that.

--
pete
Nov 14 '05 #17

"Merrill & Michele" <be********@comcast.net> wrote in message
news:l4********************@comcast.com...

"Mike Wahler"
"Merrill & Michele"
#include <stdio.h>
int main(void)
{
int i = 0;
++ i; ++ i;
printf("i equals %d\n", i);
return 0;
}

I've been trying to determine the great and manifold uses of the semicolon in c.
There's only *one* use. To terminate a statement.
It's not such an easy thing.


Sure it is. It's a syntactical element that has only
one meaning, unlike some others whose meaning depends
upon context (e.g. the '&' character).
Q1) Is the above prog conforming?


Yes.
My
compiler likes it just fine. Q2) If so, how many statements are in

main?

Five.


Along the same lines, the following code compiles for me:

static int doNothing1(void)
{
return 0;
}
int main(void)
{
int a = 0;
int b = 0;
int c = 0;
int d = 0;
int e = 0;
void doNothing2(void);

doNothing1();
doNothing2();

return 0;
}

void doNothing2(void)
{
}

Q1) Does this prog conform?


Yes.
Q2) If yes, then how many statements are in each of the 3 functions?


If Keith T's assertion is correct (and I believe it is),
that declarations aren't statements, then:

doNothing1() contains one statement.
doNothing2() contains no statements.
main() contains three statements.

-Mike
Nov 14 '05 #18

"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:Os****************@newsread1.news.pas.earthli nk.net...

"Merrill & Michele" <be********@comcast.net> wrote in message
news:l4********************@comcast.com...

"Mike Wahler"
"Merrill & Michele"
> #include <stdio.h>
> int main(void)
> {
> int i = 0;
> ++ i; ++ i;
> printf("i equals %d\n", i);
> return 0;
> }
>
> I've been trying to determine the great and manifold uses of the

semicolon
> in c.

There's only *one* use. To terminate a statement.

> It's not such an easy thing.

Sure it is. It's a syntactical element that has only
one meaning, unlike some others whose meaning depends
upon context (e.g. the '&' character).

> Q1) Is the above prog conforming?

Yes.

> My
> compiler likes it just fine. Q2) If so, how many statements are in

main?

Five.


Along the same lines, the following code compiles for me:

static int doNothing1(void)
{
return 0;
}
int main(void)
{
int a = 0;
int b = 0;
int c = 0;
int d = 0;
int e = 0;
void doNothing2(void);

doNothing1();
doNothing2();

return 0;
}

void doNothing2(void)
{
}

Q1) Does this prog conform?


Yes.
Q2) If yes, then how many statements are in each of the 3 functions?


If Keith T's assertion is correct (and I believe it is),
that declarations aren't statements, then:

doNothing1() contains one statement.
doNothing2() contains no statements.
main() contains three statements.


And if you want to include 'compound statement' and
a function body qualifies as one, then add one to
each of the above.

-Mike
Nov 14 '05 #19
Merrill & Michele wrote:
I've been trying to determine the great and manifold uses
of the semicolon in c.


I used Google

http://www.google.com/

to search for

+"semicolon" +"Pascal" +"statement" +"terminator" +"separator"

and I found lots of stuff including:

http://c2.com/cgi/wiki?SemiColon

"There's also a subtle distinction between ';'
as a statement terminator (C/C++/Java) and
as a statement separator (PASCAL)."
Nov 14 '05 #20

"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:5u****************@newsread1.news.pas.earthli nk.net...

"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:Os****************@newsread1.news.pas.earthli nk.net...

"Merrill & Michele" <be********@comcast.net> wrote in message
news:l4********************@comcast.com...

"Mike Wahler"
> "Merrill & Michele"
> > #include <stdio.h>
> > int main(void)
> > {
> > int i = 0;
> > ++ i; ++ i;
> > printf("i equals %d\n", i);
> > return 0;
> > }
> >
> > I've been trying to determine the great and manifold uses of the
semicolon
> > in c.
>
> There's only *one* use. To terminate a statement.
>
> > It's not such an easy thing.
>
> Sure it is. It's a syntactical element that has only
> one meaning, unlike some others whose meaning depends
> upon context (e.g. the '&' character).
>
> > Q1) Is the above prog conforming?
>
> Yes.
>
> > My
> > compiler likes it just fine. Q2) If so, how many statements are in main?
>
> Five.

Along the same lines, the following code compiles for me:

static int doNothing1(void)
{
return 0;
}
int main(void)
{
int a = 0;
int b = 0;
int c = 0;
int d = 0;
int e = 0;
void doNothing2(void);

doNothing1();
doNothing2();

return 0;
}

void doNothing2(void)
{
}

Q1) Does this prog conform?


Yes.
Q2) If yes, then how many statements are in each of the 3 functions?


If Keith T's assertion is correct (and I believe it is),
that declarations aren't statements, then:

doNothing1() contains one statement.
doNothing2() contains no statements.
main() contains three statements.


And if you want to include 'compound statement' and
a function body qualifies as one, then add one to
each of the above.


If A then A. pete has to have something to say about this. MPJ
Nov 14 '05 #21
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> writes:
Keith Thompson wrote:
Mike Wahler writes:
[...]
A declaration is a statement. No, it isn't, according to the grammar in the standard.
A "statement" can be any of the following:
labeled-statement
compound-statement
expression-statement
selection-statement
iteration-statement
jump-statement


Honestly Keith,

You remind me of Beetle Bailey's friend Zero.


You remind me of E. Robert Tisdale. Oh, wait ...
You take the statements in the standard
just a little too literally.
Not in this case.
According to
the American Heritage Dictionary of the English language

[...]

In C, statements and declarations are two different things. Both are
technical terms; the definitions in an English dictionary are not
particularly relevant. Using the terms loosely makes it difficult or
impossible to communicate.

And I think you know that.

In C90, declarations must precede statements within a compound
statement; in C99, they can be mixed.

If you didn't know that declarations and statements are two different
things, you wouldn't have any way of knowing what that statement
means. (Note that I've used the word "statement" here both in its
technical C sense and in its common English sense; the distinction is
clear from context.)

If I refer to a "character" in the context of a C program, are you
going to think I'm talking about Hamlet?

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #22
"Lawrence Kirby" <lk****@netactive.co.uk> wrote in message
news:pa****************************@netactive.co.u k...
On Fri, 17 Dec 2004 14:37:53 +0000, Alex Fraser wrote:
Part of the definition of main is the compound-statement, from the '{'
to the '}' inclusive. A compound-statement is a statement, so if you
count that too, then the answer is five.


Interestingly this is an example (and the only one) of when a compound
statement ISN'T a statement. Check the grammar.


I understand why you say that (of course, I wrote my previous post with the
grammar in front of me: I have a good memory, but not /that/ good :). I
considered that you can look at this way: a recogniser for a statement would
accept a compound-statement, therefore a compound-statement is a (kind of)
statement. Perhaps that's not really valid, I'm not sure.

Alex
Nov 14 '05 #23
"Dik T. Winter" <Di********@cwi.nl> writes:
In article <ln************@nuthaus.mib.org> Keith Thompson
<ks***@mib.org> writes:
> The claim that this "compound-statement" is not a "statement" is based
> on a painfully literal reading of the grammar.


Depends on which way you wish to go in the grammar. A compound-statement
is a specific form of a statement (and has been so since the introduction
of the term in Algol 60). So, by all means, the function body is a
statement of particular form (and that was not the case in Algol 60).
In my opinion when Lawrence wrote that that particular compound-statement
was not a statement, he was wrong.


First, let me say that it's really not a very important question; it's
a trivial issue of interest mostly to annoying pedants like me (and
non-annoying pedants like the rest of you who haven't stopped reading
yet).

Let's look at a simple function definition:

int foo(void)
{
return 42;
}

and see how it's parsed.

The whole thing is a function-definition, which expands to:

declaration-specifiers declarator declaration-list(opt) compound-statement

The sub-parts correspond to "int", "foo(void)", (nothing), and
"{ return 42; }", respectively. (I'm not quite certain about the
first three, but the compound-statement is what we're concerned with
here.)

A compound-statement expands to:

{ block-item-list(opt) }

where a block-item-list is a sequence of one or more declarations or
statements (this is in C99; C90 is a bit different here). Obviously
the '{' and '}' match the '{' and '}' delimiters. The block-item-list
matches the sequence consisting of the single statement "return 42;".

At no point in the parsing process is "{ return 42; }" parsed as a
"statement", even though that same token sequence could be a
"statement" if it appeared in a different context.

Similarly, the token sequence "42;" could be a statement (specifically
an expression-statement) if it appeared in a different context, but it
isn't one here.

Q.E.D. (Quite Easily Done)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #24
In addition to terminating statements and declarations, semicolons are
also part of the grammar of a "for" statement. (And of course they
can appear in character constants, string literals, and comments.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #25
"Merrill & Michele" <be********@comcast.net> writes:
"Mike Wahler"
"Merrill & Michele"
[...] [OT to Mr. Thompson] Q3) Are the attribution arrows correct? MPJ


The indentation levels seem to be correct, but you're still doing
something odd. It's usual to use at least something like "So-and-so
wrote:" rather than just "So-and-so".

You've also modified Mike Wahler's attribution of your previous
article. His attribution was

] "Merrill & Michele" <be********@comcast.net> wrote in message
] news:lL********************@comcast.com...

but you shortened it to just

] "Merrill & Michele"

Why? Are you doing this manually?

As I've mentioned before, you seem to be using Microsoft Outlook
Express. A lot of other people use the same software, and don't seem
to have any trouble with attributions. The software should do it for
you. I don't know what you're doing, or why. And I don't
particularly care, except that it makes your articles even harder to
read than they already are.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #26
Merrill & Michele wrote:
.... snip ...
I believe Mr. Kirby refers to a statement such as:
i = 6; ++j;
and calls this a compound statement. I can speculate on how many
statements it is and know that I could get it right if I got two
swings at the pitch. I will drag this forum wildly OT if I start
into English grammar and its inability to express truth about
number, so which is it? MPJ


It is two statements. If enclosed by {} it would be one statement,
which happens to be compound, and to consist of two statements.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!

Nov 14 '05 #27
Merrill & Michele <be********@comcast.net> scribbled the following:
"Lawrence Kirby"
> Alex Fraser wrote:
> Part of the definition of main is the compound-statement, from the '{' to > the '}' inclusive. A compound-statement is a statement, so if you count that > too, then the answer is five.
Interestingly this is an example (and the only one) of when a compound
statement ISN'T a statement. Check the grammar.

[uses cordless keyboard+mouse for 1st time and wonders how he endured life
before] I believe Mr. Kirby refers to a statement such as:
i = 6; ++j;
and calls this a compound statement. I can speculate on how many statements
it is and know that I could get it right if I got two swings at the pitch.
I will drag this forum wildly OT if I start into English grammar and its
inability to express truth about number, so which is it? MPJ


The C language (not the C preprocessor) does not group anything by
lines. It considers spaces and newlines as equivalent whitespace.
Therefore two statements on the same line is the same thing as two
consecutive lines with one statement on each.
This also means that i = 6; ++j; is two statements, not a compound
statement.
As has been said before, if you want BASIC, you know where to find it.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"Normal is what everyone else is, and you're not."
- Dr. Tolian Soran
Nov 14 '05 #28
"Keith Thompson" <ks***@mib.org> wrote in message
news:ln************@nuthaus.mib.org...
In addition to terminating statements and declarations, semicolons are
also part of the grammar of a "for" statement.
I can't believe I forgot about 'for' loops.

Time for a nap (or a drink, or... ) :-)
(And of course they
can appear in character constants, string literals, and comments.)


I thought about those, but discarded them, since in
such contexts, the're not being used as part of
the language itself (I suppose someone will
disagree with that, though. :-))

Btw I move that we change the title of this thread to
Much Ado About Nothing; :-)

-Mike
Nov 14 '05 #29
I've thought of a simpler argument in the debate over whether the
compound-statement in a function-definition is a statement.

Some excerpts from the C99 grammar:

statement:
labeled-statement
compound-statement
expression-statement
selection-statement
iteration-statement
jump-statement

compound-statement:
{ block-item-list(opt) }

function-definition:
declaration-specifiers declarator declaration-list(opt) compound-statement

Clearly a compound-statement is a kind of statement if it appears in a
statement context. If it appears in a different context, the only
real basis for claiming that it's a "statement" is that the name of
the construct ends in "-statement".

Consider the following grammar:

statement:
labeled-statement
block
expression-statement
selection-statement
iteration-statement
jump-statement

block:
{ block-item-list(opt) }

function-definition:
declaration-specifiers declarator declaration-list(opt) block

The only change is that I've relaced the term "compound-statement"
with "block". This grammar describes exactly the same language as the
actual C99 grammar. But if the C grammar were defined this way, it
would be obvous that the block in a function-definition is *not* a
statement; it's just a block.

Geerically, it's natural to assume that if the grammar refers to
something as an ADJECTIVE-NOUN, an ADJECTIVE-NOUN must be a kind of
NOUN. That's common sense based on the rules of English, but the C
grammar isn't written in English, even though it uses a lot of English
and English-like words. In this case, there's a specific definition
of what a NOUN is, and the definition shows that not all
ADJECTIVE-NOUNs are NOUNs. (Even in plain English, a silverfish is
not a fish.)

I think we have to assume that "compound-statement" is a single term
defined by the grammar, not a phrase to be interpreted according to
its parts. It looks like a phrase, and it was obviously chosen to
imply that a compound-statement is a kind of statement, but this is
overridden by the explicit definition that says it isn't.

(And if ERT wanted to give me a hard time for being too literal, this
would have been a good opportunity.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #30

"Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message
news:cq**********@oravannahka.helsinki.fi...
Merrill & Michele <be********@comcast.net> scribbled the following:
"Lawrence Kirby"
> Alex Fraser wrote:
> Part of the definition of main is the compound-statement, from the
'{' to
> the '}' inclusive. A compound-statement is a statement, so if you
count that
> too, then the answer is five.

Interestingly this is an example (and the only one) of when a compound
statement ISN'T a statement. Check the grammar.
[uses cordless keyboard+mouse for 1st time and wonders how he endured

life before]

I believe Mr. Kirby refers to a statement such as:
i = 6; ++j;
and calls this a compound statement. I can speculate on how many statements it is and know that I could get it right if I got two swings at the pitch. I will drag this forum wildly OT if I start into English grammar and its
inability to express truth about number, so which is it? MPJ


The C language (not the C preprocessor) does not group anything by
lines. It considers spaces and newlines as equivalent whitespace.
Therefore two statements on the same line is the same thing as two
consecutive lines with one statement on each.
This also means that i = 6; ++j; is two statements, not a compound
statement.
As has been said before, if you want BASIC, you know where to find it.


This might be much ado about nothing, but I didn't know that the language
considers whitespace and newlines as equivalent in this context. MPJ
Nov 14 '05 #31
Merrill & Michele <be********@comcast.net> scribbled the following:
"Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message
news:cq**********@oravannahka.helsinki.fi...
The C language (not the C preprocessor) does not group anything by
lines. It considers spaces and newlines as equivalent whitespace.
Therefore two statements on the same line is the same thing as two
consecutive lines with one statement on each.
This also means that i = 6; ++j; is two statements, not a compound
statement.
As has been said before, if you want BASIC, you know where to find it.
This might be much ado about nothing, but I didn't know that the language
considers whitespace and newlines as equivalent in this context. MPJ


Well, now you do.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"You can pick your friends, you can pick your nose, but you can't pick your
relatives."
- MAD Magazine
Nov 14 '05 #32
"Merrill & Michele" <be********@comcast.net> wrote in message
news:NL********************@comcast.com...
This might be much ado about nothing, but I didn't know that the language
considers whitespace and newlines as equivalent in this context. MPJ


Context doesn't matter in this case. The newline character is
specifically defined as a member of the set known as 'whitespace
characters'.

-Mike
Nov 14 '05 #33

"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:Ed*****************@newsread1.news.pas.earthl ink.net...
"Merrill & Michele" <be********@comcast.net> wrote in message
news:NL********************@comcast.com...
This might be much ado about nothing, but I didn't know that the language considers whitespace and newlines as equivalent in this context. MPJ


Context doesn't matter in this case. The newline character is
specifically defined as a member of the set known as 'whitespace
characters'.


Another nuance. What all belongs to whitespace char family? MPJ
Nov 14 '05 #34
In article <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:
....
Clearly a compound-statement is a kind of statement if it appears in a
statement context. If it appears in a different context, the only
real basis for claiming that it's a "statement" is that the name of
the construct ends in "-statement".


Wait a moment. Is 42 an expression?

My reasoning is *not* based on the name, it is based on the production
rules. "statement" is the only production rule that produces
"compound-statement" without anything else. And that is why I say that
it is a particular form of a statement. Your point would have been
stronger when the syntax had been:
function-definition:
declaration-specifiers declarator declaration-list(opt) function-body
function-body:
compound-statement
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Nov 14 '05 #35
Merrill & Michele wrote:
Another nuance. What all belongs to whitespace char family? MPJ


(space, horizontal tab, new-line, vertical tab, and form-feed)

--
pete
Nov 14 '05 #36

"pete" <pf*****@mindspring.com> wrote in message
news:41***********@mindspring.com...
Merrill & Michele wrote:
Another nuance. What all belongs to whitespace char family? MPJ


(space, horizontal tab, new-line, vertical tab, and form-feed)


I'm always glad when pete is the man who has the back of the man who needs
to use hemorrhoidal creme. These must have representations not linked to
integers. I threw away K&R2 today. MPJ
Nov 14 '05 #37

"Dik T. Winter" <Di********@cwi.nl> wrote in message
news:I8********@cwi.nl...
In article <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes: ...
> Clearly a compound-statement is a kind of statement if it appears in a
> statement context. If it appears in a different context, the only
> real basis for claiming that it's a "statement" is that the name of
> the construct ends in "-statement".
Wait a moment. Is 42 an expression?

My reasoning is *not* based on the name, it is based on the production
rules. "statement" is the only production rule that produces
"compound-statement" without anything else.


Dat is a violation of Engishgrammatik. You need something unidexed here.
(Chomsky, Kerek, bla, bla )

And that is why I say that it is a particular form of a statement. Your point would have been
stronger when the syntax had been:
function-definition:
declaration-specifiers declarator declaration-list(opt) function-body
function-body:
compound-statement
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131 home: bovenover 215, 1025 jn amsterdam, nederland;

http://www.cwi.nl/~dik/

Wie kann man mit nem Keyboard snakken? MJP
Nov 14 '05 #38
Merrill & Michele <be********@comcast.net> scribbled the following:
I'm always glad when pete is the man who has the back of the man who needs
to use hemorrhoidal creme. These must have representations not linked to
integers. I threw away K&R2 today. MPJ


I actually had a dream about you last night. Well, you didn't actually
appear in my dream. I was talking with other clc regulars (I don't
remember who) and we talked about you sometimes making sense and
sometimes not.
Are you one or two people? You name yourself as "Merrill & Michele" in
your posts. Is it Merrill or Michele who writes here?

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"I am looking for myself. Have you seen me somewhere?"
- Anon
Nov 14 '05 #39
"Dik T. Winter" <Di********@cwi.nl> writes:
In article <ln************@nuthaus.mib.org> Keith Thompson
<ks***@mib.org> writes:
...
> Clearly a compound-statement is a kind of statement if it appears in a
> statement context. If it appears in a different context, the only
> real basis for claiming that it's a "statement" is that the name of
> the construct ends in "-statement".
Wait a moment. Is 42 an expression?


Yes, why do you ask?
My reasoning is *not* based on the name, it is based on the production
rules. "statement" is the only production rule that produces
"compound-statement" without anything else. And that is why I say that
it is a particular form of a statement. Your point would have been
stronger when the syntax had been:
function-definition:
declaration-specifiers declarator declaration-list(opt) function-body
function-body:
compound-statement


I don't follow your reasoning. In particular, I don't see how the
"without anything else" is relevant.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #40
Merrill & Michele wrote:
"pete" <pf*****@mindspring.com> wrote in message
news:41***********@mindspring.com...
Merrill & Michele wrote:
Another nuance. What all belongs to whitespace char family? MPJ

(space, horizontal tab, new-line, vertical tab, and form-feed)


I'm always glad when pete is the man who has the back of the man who needs
to use hemorrhoidal creme. These must have representations not linked to
integers. I threw away K&R2 today. MPJ


In reverse order:
Your loss.
' ', '\t', '\n', '\v', '\f'; pete forgot '\r' (carriage return); just
read K&R2 -- oh, too late.
I hereby award you the questionable order of the *PLONK*.

-Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 14 '05 #41
Merrill & Michele wrote:
"Mike Wahler" <mk******@mkwahler.net> wrote in message
"Merrill & Michele" <be********@comcast.net> wrote in message
This might be much ado about nothing, but I didn't know that
the language considers whitespace and newlines as equivalent
in this context. MPJ


Context doesn't matter in this case. The newline character is
specifically defined as a member of the set known as
'whitespace characters'.


Another nuance. What all belongs to whitespace char family?


Read the standard. Basically whatever the routines introduced by
ctype.h say. You can't be specific, because char sets vary.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!

Nov 14 '05 #42
Michael Mair wrote:

Merrill & Michele wrote:
"pete" <pf*****@mindspring.com> wrote in message
news:41***********@mindspring.com...
Merrill & Michele wrote:

Another nuance. What all belongs to whitespace char family? MPJ
(space, horizontal tab, new-line, vertical tab, and form-feed)
' ', '\t', '\n', '\v', '\f'; pete forgot '\r' (carriage return); just
read K&R2 -- oh, too late.


The description of isspace in the standard
gives all of the whitespace characters.

But, I had searched the rest of the standard first for "white space"
and found a couple of short lists.

--
pete
Nov 14 '05 #43
pete wrote:
Merrill & Michele wrote:

Another nuance. What all belongs to whitespace char family? MPJ

(space, horizontal tab, new-line, vertical tab, and form-feed)


And carriage return ('\r').
--
Joe Wright mailto:jo********@comcast.net
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 14 '05 #44

"Merrill & Michele" <be********@comcast.net> wrote in message
news:8f********************@comcast.com...

"pete" <pf*****@mindspring.com> wrote in message
news:41***********@mindspring.com...
Merrill & Michele wrote:
Another nuance. What all belongs to whitespace char family? MPJ
(space, horizontal tab, new-line, vertical tab, and form-feed)


I'm always glad when pete is the man who has the back of the man who needs
to use hemorrhoidal creme. These must have representations not linked to
integers.


The values of all those characters are integers, their
exact values being implmentation-specific.

I threw away K&R2 today.


What a pity.

-Mike
Nov 14 '05 #45

"Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message
news:cq**********@oravannahka.helsinki.fi...
Merrill & Michele <be********@comcast.net> scribbled the following:
I'm always glad when pete is the man who has the back of the man who needs to use hemorrhoidal creme. These must have representations not linked to integers. I threw away K&R2 today. MPJ


I actually had a dream about you last night. Well, you didn't actually
appear in my dream. I was talking with other clc regulars (I don't
remember who) and we talked about you sometimes making sense and
sometimes not.
Are you one or two people? You name yourself as "Merrill & Michele" in
your posts. Is it Merrill or Michele who writes here?

I don't make a clear path through the exegetics. My real voice is
unverkennbar. You will decide for yourself how many persons I am when we
meet. We dream on the same see and sea the same tranquility of the moon.
Some day I shall have a cabin in your country where I shall play chess with
the great bear in the chornie nachee. MPJ
Nov 14 '05 #46

"Michael Mair" <Mi**********@invalid.invalid> wrote in message
news:32*************@individual.net...
Merrill & Michele wrote:
"pete" <pf*****@mindspring.com> wrote in message
news:41***********@mindspring.com...
Merrill & Michele wrote:

Another nuance. What all belongs to whitespace char family? MPJ
(space, horizontal tab, new-line, vertical tab, and form-feed)


I'm always glad when pete is the man who has the back of the man who needs to use hemorrhoidal creme. These must have representations not linked to integers. I threw away K&R2 today. MPJ


In reverse order:
Your loss.
' ', '\t', '\n', '\v', '\f'; pete forgot '\r' (carriage return); just
read K&R2 -- oh, too late.
I hereby award you the questionable order of the *PLONK*.


Please refrain from using poor English where I have to read it. How could
hemorrhoids be germane to c? Because I've been scratching my ass like
someone possessed for the last few weeks. You try, in polite conversation,
to use euphemisms with your snickering wife. Thus, semicolon. Hemorrhoids
was a joke but missing a semicolon gets you axed around me. Tschueß, jens.
Nov 14 '05 #47
"Merrill & Michele" <be********@comcast.net> writes:
[...]
I threw away K&R2 today. MPJ


You fool(s).

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #48
"Merrill & Michele" <be********@comcast.net> writes:
[...]
Please refrain from using poor English where I have to read it.

[...]

You've become boring. I don't use a killfile, but I will no longer
spend the considerable time and effort necessary to figure out what
you're talking about. If you post something topical and
understandable, I may respond. Otherwise, I give up on you.

Bye.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #49

"Keith Thompson" <ks***@mib.org> wrote in message
news:ln************@nuthaus.mib.org...
"Merrill & Michele" <be********@comcast.net> writes:
[...]
Please refrain from using poor English where I have to read it.

[...]

You've become boring. I don't use a killfile, but I will no longer
spend the considerable time and effort necessary to figure out what
you're talking about. If you post something topical and
understandable, I may respond. Otherwise, I give up on you.

Bye.


K&R2 is missing ; in the index. MPJ
Nov 14 '05 #50

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: craig | last post by:
I am working on my first .NET development project that involves custom role-based security per the project requirements. This lead to a general design issue this week that really caused us some...
11
by: fritz | last post by:
Hi, When I look through the "javascript bible" I don't find any example scripts that have lines with ending semicolons. However when I peruse this newsgroup I find that sometimes there are ending...
6
by: Merrill & Michele | last post by:
I know that for my own programs, the things that precede the main call are either remarks or begin with a hash. What else can you put up there? MPJ
3
by: Dan | last post by:
I'm writing a record from an asp.net page to SQL Server. After the insert I'm selecting @@identity to return the ID of the record that I just wrote. It worked fine until I typed a semicolon into...
4
by: cybertoast | last post by:
i seem to have some misunderstanding about how roles work in sql server 2005. i see that i can add a role to a database (dbname->->properties->permissions->. THis allows me to add either users or...
1
by: Lawrence San | last post by:
According to a JavaScript debugger (Firebug), and to a JS lint, this is fine: function recalc(){deriv = 6;} But, if I've assigned the function to a variable like this: var bells =...
3
by: Peter Michaux | last post by:
Hi, These first three links say that when reading document.cookie the name-value pairs are separated by semicolons and they show examples like "name=value;expires=date" where there is clearly...
3
by: Ken | last post by:
Hi all, I want to printf a sentence with a semicolon, for examples: printf(" I like C language; You like C++ language."); But C compiler alway identify the semicolon as a end of a sentence and...
2
by: Anthony Smith | last post by:
I have a user object that is set when a user logs in. There are also permissions that I get about the user from a web service. Currently I take the results from those web services and store them as...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.