C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Confused about the "Meaning" of the Semicolon

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Sebastian
Guest





PostPosted: Sun Nov 28, 2004 11:54 pm    Post subject: Confused about the "Meaning" of the Semicolon Reply with quote



I recently found out that I have no real understanding of the use of
semicolons in the C++ language. I know that a "statement" ends with a
semicolon, but that only means that I don't understand what a
"statement" is.

I recently found out that I am still confused about this by looking at
a function declaration and definition:

int add(int iNumber1, int iNumber2)
{
return (iNumber1 + iNumber2);
} //look, no semicolon

I used to believe that there should be a semicolon after this last
brace.
But NO, you do not have to put a semicolon here.

If I had decided to prototype my "add function" earlier in the code, I
could proceed as follows

int add( int iNumber1, int iNumber2);
//Prototype declaration. Yes, semicolon needed here.

//...some code....

//definition of function prototyped earlier on:
int add(int iNumber1, int iNumber2)
{
return (iNumber1 + iNumber2);
} //look, no semicolon

My thinking used to be: In case I prototype a function, the semicolon
doesn't have to show up in the definition because it showed up in the
prototype declaration.
But if I declare and define together, then the semicolon has to show
up after the definition.

My understanding of the semicolon was something like a "Do it!" or
"Create!" symbol, something that has to happen for every entity
created in the program at some time. But in my first example -which is
apparently legal- the semicolon simply doesn't show up! So that theory
goes out the window...

What's the REAL definition of the semicolon?

Thanks in advance,

Sebastian.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Jack Klein
Guest





PostPosted: Mon Nov 29, 2004 11:01 am    Post subject: Re: Confused about the "Meaning" of the Semicolon Reply with quote



On 28 Nov 2004 18:54:12 -0500, [email]sebastian (AT) donnersmarck (DOT) com[/email] (Sebastian)
wrote in comp.lang.c++.moderated:

Quote:
I recently found out that I have no real understanding of the use of
semicolons in the C++ language. I know that a "statement" ends with a
semicolon, but that only means that I don't understand what a
"statement" is.

I recently found out that I am still confused about this by looking at
a function declaration and definition:

int add(int iNumber1, int iNumber2)
{
return (iNumber1 + iNumber2);
} //look, no semicolon

I used to believe that there should be a semicolon after this last
brace.
But NO, you do not have to put a semicolon here.

If I had decided to prototype my "add function" earlier in the code, I
could proceed as follows

int add( int iNumber1, int iNumber2);
//Prototype declaration. Yes, semicolon needed here.

//...some code....

//definition of function prototyped earlier on:
int add(int iNumber1, int iNumber2)
{
return (iNumber1 + iNumber2);
} //look, no semicolon

My thinking used to be: In case I prototype a function, the semicolon
doesn't have to show up in the definition because it showed up in the
prototype declaration.
But if I declare and define together, then the semicolon has to show
up after the definition.

My understanding of the semicolon was something like a "Do it!" or
"Create!" symbol, something that has to happen for every entity
created in the program at some time. But in my first example -which is
apparently legal- the semicolon simply doesn't show up! So that theory
goes out the window...

What's the REAL definition of the semicolon?

Thanks in advance,

The semicolon is a "punctuator", a term not defined in great detail by
the standard.

The C++ grammar is based on the C grammar, and it is specified
directly, not derived from rules. Furthermore, in the early days of
C, it appears that it was developed in a rather ad-hoc manner, not by
applying a pre-defined strategy. In many cases, semicolons are either
required or not based whether their presence simplified coding of the
compiler.

In the early days of C, before it inherited prototypes from C++,
function definitions included "identifier lists", for example looked
like this:

double some_func(x)
int x;
{
return x * 2.0;
}

So you can see the problem is a function declaration did not end with
a semicolon and was followed by an object definition.

Likewise, the semicolon is required in places where a sequence up to
that point could be complete, or could be part of a larger overall
declaration or statement. Consider:

struct fred { int x; long y };
main()
{
return 0;
}

Note that the 'implicit int' definition of the return type of main()
is illegal in both C and C++ today, but many of the grammar rules date
from days when it was not (at least in C).

Minus the semicolon at then end of the structure definition, the
source would define the function main() as returning a 'struct fred',
not an int.

What it all boils down to is that semicolons are required where the
grammar specifies they are required, and this is not based on some
overriding principle.

Among the types of statements are 'expression-statement' and
'compound-statement'. An 'expression-statement' is defined as:

expression(opt) ;

....that is an optional expression followed by a ';' (the expression is
optional to allow for the null statement).

A 'compound-statement' is defined as:

{ statement-seq (opt) }

....where 'statement-seq' is defined as:

statement
statement-seq statement

A function declaration falls under the type 'simple-declaration', and
the grammar specifies that such declarations require a terminating
semicolon. A function definition ends with a function body, and a
function body is defined as a compound statement, and a compound
statement is defined as being terminated by the closing '}' and not by
a semicolon.

You can't really deduce the places where a semicolon is required or
forbidden from any abstract first principle. You perhaps could if you
tried to implement a compiler for the early version of C defined in
the first edition of Kernighan & Ritchie's C Programming Language,
based on the grammar included in that book. Of course, both C and
itself and C++ much more so have extended the language and therefore
the grammar since then.

The grammar for ISO C++ in included in appendix A of ISO 14882, but it
will not spell out the "whys".

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


Back to top
Ron Natalie
Guest





PostPosted: Mon Nov 29, 2004 11:04 am    Post subject: Re: Confused about the "Meaning" of the Semicolon Reply with quote



Sebastian wrote:
Quote:
I recently found out that I have no real understanding of the use of
semicolons in the C++ language. I know that a "statement" ends with a
semicolon, but that only means that I don't understand what a
"statement" is.

The issue is not the meaning of semicolon. The semicolon is just punctuation.

The issue is you don't seem to understand the definition of a statement.

Not all statements end in semicolons.
Not all lines of C++ code are statements. Some are declarations.
Prototype is a C term. They're just function declarations in C++.

You'll just have to learn the grammer:

Quote:
int add(int iNumber1, int iNumber2)
{
return (iNumber1 + iNumber2);
} //look, no semicolon

What you have here is a function definition. It doesn't end in
semicolon because the function definition grammer is (essentially)

declarator comppund-statement

Where compound-statemnt is a pair of braces with zero or more more
statements inside.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Francis Glassborow
Guest





PostPosted: Mon Nov 29, 2004 9:42 pm    Post subject: Re: Confused about the "Meaning" of the Semicolon Reply with quote

In article <b013ae1a.0411280754.4ba194d8 (AT) posting (DOT) google.com>, Sebastian
<sebastian (AT) donnersmarck (DOT) com> writes
Quote:
What's the REAL definition of the semicolon?
A raised point over a comma Smile


What is the real meaning of a full stop in English?

In C++ ';' occurs in various parts of the grammar, mostly in clause 6 of
the Standard which tells you what a statement is.

--
Francis Glassborow ACCU
Author of 'You Can Do It!' see http://www.spellen.org/youcandoit
For project ideas and contributions: http://www.spellen.org/youcandoit/projects


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Tokyo Tomy
Guest





PostPosted: Tue Nov 30, 2004 10:53 am    Post subject: Re: Confused about the "Meaning" of the Semicolon Reply with quote

[email]sebastian (AT) donnersmarck (DOT) com[/email] (Sebastian) wrote in message news:<b013ae1a.0411280754.4ba194d8 (AT) posting (DOT) google.com>...
Quote:
I recently found out that I have no real understanding of the use of
semicolons in the C++ language. I know that a "statement" ends with a
semicolon, but that only means that I don't understand what a
"statement" is.


Semicolon in C++ is the delimiter which separate statements. Other
computer languages use other delimiters, for example Basic uses New
Line ( return and feed) as the delimiter. In C++, Directives such as
#include use New Line as the delimiter.

A good thing for Semicolon is that you can write a statement in multi
lines.

y = x*x *x + 3*x*x
+ 4*x + 5;

But in the case of New Line, you have to write a special mark to show
a continuity of a statement for multi lines.

#define TOWN_NAME // shows continuity
Kokubunji_shi

{} brace is used for multi statements (a composite of statements) and
form a scope, and need no following semicolon, probably because {}
brace itself is a kind of delimiter.

You cannot write {y = x + 1} but { y = x + 1; }. I think this is
because the semicolon and {} have a deferent meaning: the semicolon is
a sequence point for evaluation, and {} is a scope.

"{};" is possible, but I advise you not to write the semicolon after
{} in this case.

However you have to write a semicolon after {} in the case of class or
struct definition.
class A{}; // If you drop the semicolon, a complier error will be
issued.

This is a heritage from C struct, which allow you a tag syntax , which
is sometimes used in C++ conveniently.

struct A{} tag;

Therefore, "struct A{};" means no tag.

I often forget to write the required semicolon after {}, and the
semicolon is bothering for me to write, but I can easily find the end
of a class or struct definition by the semicolon, even if it is long
and complicated.

Any correction is welcomed.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


Back to top
Ron Natalie
Guest





PostPosted: Tue Nov 30, 2004 11:12 pm    Post subject: Re: Confused about the "Meaning" of the Semicolon Reply with quote

Tokyo Tomy wrote:
Quote:
Semicolon in C++ is the delimiter which separate statements.

INCORRECT! This is exactly the bogus thinking that lead to the
original poster's confusion.

Semicolon, is the a syntactic punctuation that is required in
declearations, and certain definitions and statemnts in C++.

Quote:
{} brace is used for multi statements (a composite of statements) and
form a scope, and need no following semicolon, probably because {}
brace itself is a kind of delimiter.

In many cases braces denote a compound statement, which by the language
grammar has no semicolon. So yes, braces are "alternate punctuation"
in this use.


Quote:
You cannot write {y = x + 1} but { y = x + 1; }. I think this is
because the semicolon and {} have a deferent meaning: the semicolon is
a sequence point for evaluation, and {} is a scope.

No, the reason the semicolon is present inside the braces is that a
compound statement is a set of braces with zero or more statements inside.
The semicolon here doesn't divide anything (nor is it a sequence point
which is a completely distinct concept). It is the required end of the
expression-statement (esseintially an expression followed by a semicolon
is an expression-statement, perhaps the simplenst form of statement).

Quote:
"{};" is possible, but I advise you not to write the semicolon after
{} in this case.

It might be possible, but it would be WRONG in almost all cases. The ";"
following a compound statement just makes another statement. It would
only be allowed by the compiler in the case that another statement would
be allowed there.
if(condition1) {
// compound statement
};
This is just an if, followed by a null statement.
if(condition1) {
};
else foo();
would be ill-formed, as the ; inserts a statement between the if and the
else and hence, the else isn't part of the if().


Quote:
However you have to write a semicolon after {} in the case of class or
struct definition.
class A{}; // If you drop the semicolon, a complier error will be
issued.

Here the braces aren't a compound statement, their part of a class
definitions. These require the semicolon.

Not writing the ";" here is bad and will lead to confusion as the language
expects the next identifier encountered to be something that you want to
declare of type A. You need the ; to terminate the class A definition/declaration.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Francis Glassborow
Guest





PostPosted: Tue Nov 30, 2004 11:14 pm    Post subject: Re: Confused about the "Meaning" of the Semicolon Reply with quote

In article <49c1da0b.0411292013.128cf91c (AT) posting (DOT) google.com>, Tokyo Tomy
<hosoda (AT) jtec (DOT) or.jp> writes
Quote:
A good thing for Semicolon is that you can write a statement in multi
lines.

y = x*x *x + 3*x*x
+ 4*x + 5;
I don't think it is either good or bad, just a property of the way C++

handles whitespace (which includes new line characters)

Quote:

But in the case of New Line, you have to write a special mark to show
a continuity of a statement for multi lines.

#define TOWN_NAME // shows continuity
Kokubunji_shi
Ironically, by adding the comment you break the mechanism. The backslash

bust come immediately before a newline character, nothing, not even a
space is allowed between the two if it is to be a continuation
character.

Quote:

{} brace is used for multi statements (a composite of statements) and
form a scope, and need no following semicolon, probably because {}
brace itself is a kind of delimiter.

It is because, in an appropriate context braces form a compound
statement.

Quote:

You cannot write {y = x + 1} but { y = x + 1; }. I think this is
because the semicolon and {} have a deferent meaning: the semicolon is
a sequence point for evaluation, and {} is a scope.

No, a semicolon does not provide a sequence point though it often
terminates a full expression, and it is that which has an implicit
sequence point. But there are full expressions that are not expression
statements and so do not have a following semicolon. There are also full
expressions that are followed by a semicolon but are not expression
statements. The various elements of a for loop contains several
examples.

Quote:

"{};" is possible, but I advise you not to write the semicolon after
{} in this case.

And is sometimes an error according to the strict rules of the grammar
(e.g. after a brace closing a namespace scope)

Quote:

However you have to write a semicolon after {} in the case of class or
struct definition.
class A{}; // If you drop the semicolon, a complier error will be
issued.

This is a heritage from C struct, which allow you a tag syntax , which
is sometimes used in C++ conveniently.
Indeed it is an inheritance from C but your terminology is wrong. A tag

is a name between struct, union or enum and the opening brace of the
definition. Such names are type names in C++ but not in C (something
that can be a catch). The point is that the inherited syntax allows the
declaration of entities whose type is being defined to immediately
follow the closing brace of the definition (and the same is true in
C++). So

struct X {int i; int j;} a, *a_ptr, foo(int i);

though horrible, is a perfectly valid construct in both languages. The
difference being that X is a typename in C++ but just a tag (that must
be preceded by the appropriate keyword when used) in C.

Quote:

struct A{} tag;

Therefore, "struct A{};" means no tag.
No it means that we are not declaring anything of type A at this point

in the program. To declare such things later C++ aloows

A a;

But C requires (and C++ allows)

struct A a;

Quote:

I often forget to write the required semicolon after {}, and the
semicolon is bothering for me to write, but I can easily find the end
of a class or struct definition by the semicolon, even if it is long
and complicated.

Yes, in general grep for }; which if you stick to necessary uses of
semicolons will usually identify the end of a definition of a udt.

Quote:

Any correction is welcomed.

I hope things are a little clearer now.


--
Francis Glassborow ACCU
Author of 'You Can Do It!' see http://www.spellen.org/youcandoit
For project ideas and contributions: http://www.spellen.org/youcandoit/projects


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
John G Harris
Guest





PostPosted: Wed Dec 01, 2004 10:57 pm    Post subject: Re: Confused about the "Meaning" of the Semicolon Reply with quote

In message <41ac7967$0$1634$9a6e19ea (AT) news (DOT) newshosting.com>, Ron Natalie
<ron (AT) sensor (DOT) com> writes
Quote:
Tokyo Tomy wrote:
Semicolon in C++ is the delimiter which separate statements.

INCORRECT! This is exactly the bogus thinking that lead to the
original poster's confusion.

Semicolon, is the a syntactic punctuation that is required in
declearations, and certain definitions and statemnts in C++.

{} brace is used for multi statements (a composite of statements) and
form a scope, and need no following semicolon, probably because {}
brace itself is a kind of delimiter.

In many cases braces denote a compound statement, which by the language
grammar has no semicolon. So yes, braces are "alternate punctuation"
in this use.
snip


The idea that semicolons are separators and that { .. } is not itself a
statement appears to have become an urban myth. I've even seen it in a
textbook written by Computer Science professors :-(

Is there no cure for this?

John
--
John Harris

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


Back to top
kanze@gabi-soft.fr
Guest





PostPosted: Thu Dec 02, 2004 12:52 am    Post subject: Re: Confused about the "Meaning" of the Semicolon Reply with quote

Ron Natalie <ron (AT) sensor (DOT) com> wrote

Quote:
Sebastian wrote:
I recently found out that I have no real understanding of the use
of semicolons in the C++ language. I know that a "statement" ends
with a semicolon, but that only means that I don't understand what
a "statement" is.

The issue is not the meaning of semicolon. The semicolon is just
punctuation. The issue is you don't seem to understand the definition
of a statement.

Not all statements end in semicolons. Not all lines of C++ code are
statements. Some are declarations.

In C++, declarations are statements. For some strange reason, this is
not the case in C.

More generally, of course, except for the preprocessor, lines don't mean
a thing to the compiler. You can write your entire function in one
line, even if it is a hundred statements, or you can write each token on
a separate line. (Just don't ask me to maintain your code if you follow
one of these policies. It's a good policy for the human reader to put
just one statement per line.)

As a general rule, I think it is safe to say that all statements end
with either a ';', a '}' or contained statement. (I can't think of any
exceptions off-hand.) Also, a statement will never end with more than
one of these. Think about it for a minute: the grammar of a while
statement is:

`while' `(' condition `)' statement

If a ';' were necessary to terminate a while statement, then you would
need two ';' in:

while ( x > 0 ) ++ x ; ;

the first to terminate the expression statement ++ x, and the second to
terminate the while.

--
James Kanze GABI Software http://www.gabi-soft.fr
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
kanze@gabi-soft.fr
Guest





PostPosted: Thu Dec 02, 2004 12:57 am    Post subject: Re: Confused about the "Meaning" of the Semicolon Reply with quote

[email]hosoda (AT) jtec (DOT) or.jp[/email] (Tokyo Tomy) wrote in message
news:<49c1da0b.0411292013.128cf91c (AT) posting (DOT) google.com>...
Quote:
sebastian (AT) donnersmarck (DOT) com (Sebastian) wrote in message
news:<b013ae1a.0411280754.4ba194d8 (AT) posting (DOT) google.com>...

I recently found out that I have no real understanding of the use
of semicolons in the C++ language. I know that a "statement" ends
with a semicolon, but that only means that I don't understand what
a "statement" is.

Semicolon in C++ is the delimiter which separate statements.

A semicolon in C++ is NOT a separator. It terminates (some)
statements. It does not separate anything.

Quote:
Other computer languages use other delimiters, for example Basic uses
New Line ( return and feed) as the delimiter.

More generally, some languages use terminators, like C++; others like
Pascal, use separators. Grammars using separators tend to look more
elegant (IMHO), but result in more user errors, than grammars using
terminators.

Quote:
In C++, Directives such as
#include use New Line as the delimiter.

The end of line is significant in the preprocessor, but not later.

Quote:
A good thing for Semicolon is that you can write a statement in multi
lines.

y = x*x *x + 3*x*x
+ 4*x + 5;

But in the case of New Line, you have to write a special mark to show
a continuity of a statement for multi lines.

#define TOWN_NAME // shows continuity
Kokubunji_shi

{} brace is used for multi statements (a composite of statements) and
form a scope, and need no following semicolon, probably because {}
brace itself is a kind of delimiter.

That's probably the justification. In fact, the grammar is such that it
is easy to unambiguously locate the end of each statement. Both for the
compiler and more importantly for the reader. Normally, a statement
will end with a '}', a ';' or an embedded statement (which in turn ends
with a '}', a ';' or an embedded statement, ad inifinitum).

Quote:
You cannot write {y = x + 1} but { y = x + 1; }.

Because ';' is a terminator, not a separator. And the grammar of an
expression statement requires a ';' as terminator.

In Pascal, if you replace { and } by BEGIN and END, both forms are
legal; the second defines a block with two statements: an expression
statement and an empty statement. That's the difference between a
separator and a terminator. (And I know: Pascal doesn't have expression
statements, but assignment statements, and = is the comparison operator,
you need := for assignment.)

Quote:
I think this is because the semicolon and {} have a deferent meaning:
the semicolon is a sequence point for evaluation, and {} is a scope.

Technically speaking, the semicolon is NOT a sequence point. The end of
a full expression is a sequence point. But since an expression cannot
span several statements, and a semicolon always terminates a statement,
there will always be a sequence point at a semicolon.

Quote:
"{};" is possible, but I advise you not to write the semicolon after
{} in this case.

Whether it is possible or not depends on the context. Consider:

void f() {} // No semicolon allowed.
struct C {
void g() {} // Semicolon optional.
} ; // Semicolon required.

In general, a function definition is terminated by the closing }, a
class definition no (because more may follow). Within a function, and
empty statement is allowed, however (so extra semicolons may be
tolerated), and the grammar explicitly allows an optional semicolon
after the definition of a function in a class.

And don't ask me why they didn't just allow an empty statment anywhere,
and be done with it.

Quote:
However you have to write a semicolon after {} in the case of class or
struct definition.
class A{}; // If you drop the semicolon, a complier error will be
issued.

That's because you can also write:

class A {} someVariable ;

The compiler has to know where to stop, and in this case, the closing }
is not sufficient to indicate the end of a statement.

Quote:
This is a heritage from C struct, which allow you a tag syntax , which
is sometimes used in C++ conveniently.

struct A{} tag;

Therefore, "struct A{};" means no tag.

Normally, the "tag" in the above would be A -- in your first line above,
you have defined a class type named A and a variable of type A in the
same line.

--
James Kanze GABI Software http://www.gabi-soft.fr
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Ron Natalie
Guest





PostPosted: Fri Dec 03, 2004 11:35 am    Post subject: Re: Confused about the "Meaning" of the Semicolon Reply with quote

[email]kanze (AT) gabi-soft (DOT) fr[/email] wrote:

Quote:

In C++, declarations are statements. For some strange reason, this is
not the case in C.

In C++ declarations MAY be statements. It's not too strange. A C++
declaration can be inserted at anypoint in a compound statement. A C
declaration may only appear at the beginning of the compound. A C++
"compound statement" (the terminology differs from C++), is a
{
declarations(optional)
statements (optional)
}
where in C++ it's just
{
statements (optional)
}

Quote:
As a general rule, I think it is safe to say that all statements end
with either a ';', a '}' or contained statement

I believe that is true. C++ defines 8 classes of statement.
Declaration-statements, jump-statements, and expression-statements end in semicolon.
Try-block and compound stamements end in brace. The labeled,
selection, and jump statements end in another statement. The iteration-statements
all end in a statement except for do...while, which ends in a semicolon.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


Back to top
Francis Glassborow
Guest





PostPosted: Sat Dec 04, 2004 3:53 am    Post subject: Re: Confused about the "Meaning" of the Semicolon Reply with quote

In article <41af23be$0$1547$9a6e19ea (AT) news (DOT) newshosting.com>, Ron Natalie
<ron (AT) sensor (DOT) com> writes
Quote:
A C
declaration may only appear at the beginning of the compound.

Was true for the first version of the C Standard but is not true for
versions from 1999 onwards. However WG14 amended its grammar to continue
with not calling declarations 'statements'. If you think about the
original versions where declarations had to be at the start of a block,
the reason for not including declarations in the list of statements is
obvious. These days WG14 might have had a slightly simpler grammar by
switching to the C++ form.


--
Francis Glassborow ACCU
Author of 'You Can Do It!' see http://www.spellen.org/youcandoit
For project ideas and contributions: http://www.spellen.org/youcandoit/projects


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.