S
Sensei
Hi again! Another probably silly question. I have been reading the
standard but I didn't find anything about this, at a first glance.
What does the standard say about inserting code blocks? I think the
following is valid C:
printf("hello\n");
{
printf("world\n");
}
I am thinking about the use of code blocks in order to help readability
of code that make use of "modal" function calls. One example is OpenGL:
glBegin(whatever);
glFunction1(x);
glFunction2(y);
....
glEnd();
which can be rewritten as
glBegin(whatever);
{
glFunction1(x);
glFunction2(y);
...
}
glEnd();
Do you see anything bad about this convention? What would be the
difference for the compiler in those two cases?
Thanks!
PS. I know opengl is OT, but functions like glBegin() and glEnd() can
be used in many codes. I am worried about the adherence to the standard
C, not to OpenGL or any other library. The example is here just to help
in case one knows how OpenGL should be used.
--
Sensei <Sensei's e-mail is at Mac-dot-com>
It is a very sad thing that nowadays there is so little useless information.
(Oscar Wilde)
standard but I didn't find anything about this, at a first glance.
What does the standard say about inserting code blocks? I think the
following is valid C:
printf("hello\n");
{
printf("world\n");
}
I am thinking about the use of code blocks in order to help readability
of code that make use of "modal" function calls. One example is OpenGL:
glBegin(whatever);
glFunction1(x);
glFunction2(y);
....
glEnd();
which can be rewritten as
glBegin(whatever);
{
glFunction1(x);
glFunction2(y);
...
}
glEnd();
Do you see anything bad about this convention? What would be the
difference for the compiler in those two cases?
Thanks!
PS. I know opengl is OT, but functions like glBegin() and glEnd() can
be used in many codes. I am worried about the adherence to the standard
C, not to OpenGL or any other library. The example is here just to help
in case one knows how OpenGL should be used.
--
Sensei <Sensei's e-mail is at Mac-dot-com>
It is a very sad thing that nowadays there is so little useless information.
(Oscar Wilde)