This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC's statement expression extension
- To: Marc Espie <espie at quatramaran dot ens dot fr>
- Subject: Re: GCC's statement expression extension
- From: Linus Torvalds <torvalds at transmeta dot com>
- Date: Sun, 30 Jul 2000 10:21:11 -0700 (PDT)
- cc: gcc at gcc dot gnu dot org
On Sat, 29 Jul 2000, Marc Espie wrote:
>
> The largest problem C++ currently has is C stuff that does not compile in C++
> and shows up in C headers. That makes those headers useless for C++.
>
> Statement expressions is part of the problem.
Ok.
So it's purely a C++ problem.
> This results in a tight coupling between a compiler, a language and a system.
>
> Show me how this can be a good thing.
Show me how "the world is set in stone - we have standards, and we will
never exit the boundaries of those standards" will ever be a good thing.
Any system whose only goal in life is to just adhere to standards is
essentially dead. Gcc should explore more than just standards. In fact,
gcc has become a standard of it's own - and one that other compilers are
measured up to. And that is _good_.
Things like inline functions didn't use to be part of the C standard. They
are now (or will be soon). And that's because people dared go outside the
rigid rules. That's how a language evolves, and that is what makes a
language _alive_. Judging extensions as something automatically bad is
something that old fogies do when they are afraid of change.
Now, that does NOT mean that every extension should be considered a good
one. I'm not arguing anything like that. But I do think that your
standpoint that "it is an extension so it must be bad" is narrow-minded
and ultimately stupid. Extensions must be judged on _other_ criteria.
I don't think anybody can seriously claim that statement expressions are
"bad C". A lot of people agree that they are very useful and allow for a
clean syntax for doing things that are somewhere in between a macro and an
inline function, having some of the good sides of both. C++ has templates,
but those simply would not fit into C - they are against the grain of the
language. Unlike statement expressions.
And it's a sad day indeed when a C feature gets judged on how bad it is
for C++. Like it or not, there are people who think that C++ is not the
ultimate language.
But I do understand the problem: if you want to make statement expressions
illegal in C++ (which I have no real opinion of - it's a language I don't
care for), you're screwing up one of the original advantages of C++: the
backwards compatibility with a language I _do_ care about, and one that I
want to see live on rather than die the horrid death of being forever
entomed in the cobwebs of standardization.
Could somebody explain why C++ has so many problems with statement
expressions? Maybe there is some solution to this - something that might
involve a form of statement expression-like behaviour that works on both C
and C++?
I'm not married to the syntax of statement expressions, but I think the
power they have is very useful. Maybe there is a better syntax that is
equally useful and has better semantics for C++? Exactly because the
statement expression is an extension of the language, we do have the
freedom to _improve_ on it - and if it is done well, people who used to
use the current format of statement expressions will be more than happy to
switch to a new and better way of doing the same thing.
Basically, I'm arguing for the _richness_ of the C language. But I don't
want to be arguing against C++ - and I hate the fact that you argue
against C by using C++ arguments. Maybe there is a common ground?
Linus