By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,492 Members | 1,616 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,492 IT Pros & Developers. It's quick & easy.

Name of the part after the declaration list in a block in C89

P: n/a
Hello,

in C89 (at least in the last public draft),
"3.6.2 Compound statement, or block", we have

,---
| Syntax
|
| compound-statement:
| { declaration-list<opt> statement-list<opt> }
|
| declaration-list:
| declaration
| declaration-list declaration
|
| statement-list:
| statement
| statement-list statement
`---

Now, we can call the first part/group (called declaration-list above)
"declarations" or "declaration list" etc.
My question: Is there an official or widely accepted name for the
second group (called statement list)? Ideally handy and descriptive;
"the optional group of statements after the optional declarations"
does not make me really happy...
If there is none, then I'd appreciate to know so, too.

Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 15 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Michael Mair wrote:

Hello,

in C89 (at least in the last public draft),
"3.6.2 Compound statement, or block", we have

,---
| Syntax
|
| compound-statement:
| { declaration-list<opt> statement-list<opt> }
|
| declaration-list:
| declaration
| declaration-list declaration
|
| statement-list:
| statement
| statement-list statement
`---

Now, we can call the first part/group (called declaration-list above)
"declarations" or "declaration list" etc.
My question: Is there an official or widely accepted name for the
second group (called statement list)? Ideally handy and descriptive;
"the optional group of statements after the optional declarations"
does not make me really happy...
If there is none, then I'd appreciate to know so, too.


If you're comfortable calling the declarations "declarations",
then why not refer to the statements as "statements"?

Unlike declarations, you won't find statements
anywhere else in a program.
If you say statements, it's clear that you're talking
about a function definition.

--
pete
Nov 15 '05 #2

P: n/a
pete wrote:
Michael Mair wrote:
Hello,

in C89 (at least in the last public draft),
"3.6.2 Compound statement, or block", we have

,---
| Syntax
|
| compound-statement:
| { declaration-list<opt> statement-list<opt> }
|
| declaration-list:
| declaration
| declaration-list declaration
|
| statement-list:
| statement
| statement-list statement
`---

Now, we can call the first part/group (called declaration-list above)
"declarations" or "declaration list" etc.
My question: Is there an official or widely accepted name for the
second group (called statement list)? Ideally handy and descriptive;
"the optional group of statements after the optional declarations"
does not make me really happy...
If there is none, then I'd appreciate to know so, too.
If you're comfortable calling the declarations "declarations",
then why not refer to the statements as "statements"?

Unlike declarations, you won't find statements
anywhere else in a program.


You are right; unfortunately, the intended audience will probably
struggle with seeing declarations as "not statements".
I was not clear in my question; it should rather have the addition
"apart from statements/statement list"...
If you say statements, it's clear that you're talking
about a function definition.


Or a part thereof.

Thank you for your contribution!

-Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 15 '05 #3

P: n/a
Michael Mair wrote:
unfortunately, the intended audience will probably
struggle with seeing declarations as "not statements".


Declarations describe types.
Simple (meaning not compound) statements don't describe types.

The only thing that a compound statement is required to have,
is {} a pair of braces.
It may contain declarations followed by statements,
both are optional.

The only part of a compound statement that can describe types,
is it's declarations.

{
declarations;
/* blank line */
statements;
}

.... and that's how I write the body of a function definition in C89.
The declarations in a function definition can be any kind,
except a function definition.
What could be simpler?

I try to find broad generalizations in C.

When you look at a C program, you see four things
1 comments
2 preprocessor directives
3 external declarations
4 extra white space

.... not necessarily all distinct from each other,
and comments, directives, and extra white space are all optional,
but there's nothing else that can be in a program.

The function definition is probably the most important kind
of declaration.
It is the only declaration which doesn't end in a semicolon.
It is the only declaration which can't be inside a function definition.
It is the only declaration required to be in a program.

--
pete
Nov 15 '05 #4

P: n/a
pete wrote:
Michael Mair wrote:
unfortunately, the intended audience will probably
struggle with seeing declarations as "not statements".


Declarations describe types.
Simple (meaning not compound) statements don't describe types.


The problem in this case is, for a change, not my lack of
understanding of the standard but of another way of saying
"statement list<opt>".
Thinking about it once more, I fear this will lead into
off-topic regions.

The consuments of the description already have enough flavours
of "statements" which are similar to the C statement but
unfortunately can also include "declaration statements" and
worse. In other cases, I only have a simple disambiguation to
make ("foo block <-> C block") but in this case, I would like
something different yet descriptive to avoid complete bewilderment.

Reminds of beverages which are nearly but not completely unlike
tea...

<snip: nice list of facts about compound statements and things
found in C programs>

Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 15 '05 #5

P: n/a
Michael Mair wrote:

pete wrote:
Michael Mair wrote:
unfortunately, the intended audience will probably
struggle with seeing declarations as "not statements".
Declarations describe types.
Simple (meaning not compound) statements don't describe types.


The problem in this case is, for a change, not my lack of
understanding of the standard but of another way of saying
"statement list<opt>".
Thinking about it once more, I fear this will lead into
off-topic regions.

The consuments of the description already have enough flavours
of "statements" which are similar to the C statement but
unfortunately can also include "declaration statements"


Could you tell them that C redefines some general programming terms?
It does.
Maybe you could prefix and redefine some general programming terms:
C statements, C strings, ... when discussing C.
In my Intel cpu manuals, a "string" is
something more like a C array, than a C string.
and worse. In other cases, I only have a simple disambiguation to
make ("foo block <-> C block") but in this case, I would like
something different yet descriptive to avoid complete bewilderment.

Reminds of beverages which are nearly but not completely unlike
tea...


Flavored coffee is enough to confuse my simple mind.

--
pete
Nov 15 '05 #6

P: n/a
Michael Mair <Mi**********@invalid.invalid> writes:
pete wrote:
Michael Mair wrote:
unfortunately, the intended audience will probably
struggle with seeing declarations as "not statements".

Declarations describe types.
Simple (meaning not compound) statements don't describe types.


The problem in this case is, for a change, not my lack of
understanding of the standard but of another way of saying
"statement list<opt>".
Thinking about it once more, I fear this will lead into
off-topic regions.

The consuments of the description already have enough flavours
of "statements" which are similar to the C statement but
unfortunately can also include "declaration statements" and
worse. In other cases, I only have a simple disambiguation to
make ("foo block <-> C block") but in this case, I would like
something different yet descriptive to avoid complete bewilderment.


Is there a reason that simply telling them

In C, statements and declarations are two different things;
declarations are not statements.

won't work?

--
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 15 '05 #7

P: n/a
Keith Thompson wrote:
Michael Mair <Mi**********@invalid.invalid> writes:
pete wrote:
Michael Mair wrote:
unfortunately, the intended audience will probably
struggle with seeing declarations as "not statements".

Declarations describe types.
Simple (meaning not compound) statements don't describe types.


The problem in this case is, for a change, not my lack of
understanding of the standard but of another way of saying
"statement list<opt>".
Thinking about it once more, I fear this will lead into
off-topic regions.

The consuments of the description already have enough flavours
of "statements" which are similar to the C statement but
unfortunately can also include "declaration statements" and
worse. In other cases, I only have a simple disambiguation to
make ("foo block <-> C block") but in this case, I would like
something different yet descriptive to avoid complete bewilderment.

Is there a reason that simply telling them

In C, statements and declarations are two different things;
declarations are not statements.

won't work?


Well, probably not a sufficient one from a C point of view.
I just hoped to find an alternative way of saying
"statement-list" just like I can use "block" instead of
"compound statement". Even something sufficiently close would
have sufficed.

However, I think I will try statement list once more...
Thanks
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 15 '05 #8

P: n/a
Michael Mair <Mi**********@invalid.invalid> writes:
pete wrote:
Michael Mair wrote:
Hello,

in C89 (at least in the last public draft),
"3.6.2 Compound statement, or block", we have

,---
| Syntax
|
| compound-statement:
| { declaration-list<opt> statement-list<opt> }
|
| declaration-list:
| declaration
| declaration-list declaration
|
| statement-list:
| statement
| statement-list statement
`---

Now, we can call the first part/group (called declaration-list above)
"declarations" or "declaration list" etc.
My question: Is there an official or widely accepted name for the
second group (called statement list)? Ideally handy and descriptive;
"the optional group of statements after the optional declarations"
does not make me really happy...
If there is none, then I'd appreciate to know so, too.


If you're comfortable calling the declarations "declarations",
then why not refer to the statements as "statements"?

Unlike declarations, you won't find statements
anywhere else in a program.


You are right; unfortunately, the intended audience will probably
struggle with seeing declarations as "not statements".
I was not clear in my question; it should rather have the addition
"apart from statements/statement list"...


If it were me, I'd consider calling them "executable statements", and
immediately put in a minor digression (or a footnote, if writing) and
say something like

The official defining document for C calls these just
"statements" rather than "executable statements", and
uses the term "declaration" for things like 'int i;'.
So technically we're using the wrong terminology; but
I think everyone knows what I mean if I say "executable
statement" so we're going to keep using that.

If you're doing a talk, be ready for the inevitable person
who asks about whether 'double x_squared = x * x;' is an
executable statement or not. :)
Nov 15 '05 #9

P: n/a
Tim Rentsch wrote:
Michael Mair <Mi**********@invalid.invalid> writes:

pete wrote:
Michael Mair wrote:
Hello,

in C89 (at least in the last public draft),
"3.6.2 Compound statement, or block", we have

,---
| Syntax
|
| compound-statement:
| { declaration-list<opt> statement-list<opt> }
|
| declaration-list:
| declaration
| declaration-list declaration
|
| statement-list:
| statement
| statement-list statement
`---

Now, we can call the first part/group (called declaration-list above)
"declarations" or "declaration list" etc.
My question: Is there an official or widely accepted name for the
second group (called statement list)? Ideally handy and descriptive;
"the optional group of statements after the optional declarations"
does not make me really happy...
If there is none, then I'd appreciate to know so, too.

If you're comfortable calling the declarations "declarations",
then why not refer to the statements as "statements"?

Unlike declarations, you won't find statements
anywhere else in a program.
You are right; unfortunately, the intended audience will probably
struggle with seeing declarations as "not statements".
I was not clear in my question; it should rather have the addition
"apart from statements/statement list"...

If it were me, I'd consider calling them "executable statements", and
immediately put in a minor digression (or a footnote, if writing) and
say something like

The official defining document for C calls these just
"statements" rather than "executable statements", and
uses the term "declaration" for things like 'int i;'.
So technically we're using the wrong terminology; but
I think everyone knows what I mean if I say "executable
statement" so we're going to keep using that.


This may be a viable way :-)
If you're doing a talk, be ready for the inevitable person
who asks about whether 'double x_squared = x * x;' is an
executable statement or not. :)


*g* I already fell into that one yesterday, when I was first
asked how to call that part of a block... Initializers surely
make life hard in this respect ;-)

Thank you very much :-)
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 15 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.