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

M

Michael Mair

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
 
P

pete

Michael said:
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.
 
M

Michael Mair

pete said:
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
 
P

pete

Michael said:
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.
 
M

Michael Mair

pete said:
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
 
P

pete

Michael said:
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.
 
K

Keith Thompson

Michael Mair said:
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?
 
M

Michael Mair

Keith said:
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
 
T

Tim Rentsch

Michael Mair said:
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. :)
 
M

Michael Mair

Tim said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,265
Latest member
TodLarocca

Latest Threads

Top