K
Keith Thompson
[...]jacob navia said:Philip said:jacob navia wrote:
[Compiler extensions]No, the fact that he did use them and found them useful underlinesThe fact that he did use them and found them useful underlines that this
extensions are needed. I just do not have the money and political clout
to make them into the standard.
that these extensions can be useful. Not that they are needed. If
every compiler extension that was used and found useful made it into
the standard we'd have a language several times larger than C++ by
now.
Why is operator overloading needed?
Operator overloading is needed for creating at the user's discretion
new kind of numbers.
This is completely impossible in current C, and it is needed for a wide
variety of usages, from extra precision floating point, bignumbers,
rationals, and many other usages.
Operator overloading is never actually *needed*. It's syntactic
sugar; any program written to use operator overloading can be
equivalently written without it. In fact, a tool that parses source
code with overloaded operators (using some extension with well-defined
syntax and semantics) and translates it to standard C using function
calls would probably be much easier to write than a full compiler. I
mention that merely to demonstrate that operator overloading doesn't
add anything fundamental to the language.
It certainly can be convenient, and I've used it in languages that
support it.
Ok, you don't like C++ because it's too big and complex, and you don't
like C as it's currently defined because it lacks some features that
you think are important. That's fine. So why not invent a new
language? Your compiler already supports a language that's neither C
nor C++; just give it a name and don't claim that it's C. Of course
your compiler can still continue to support standard C; multi-language
compilers aren't a new idea. You can then stop worrying about whether
your extensions violate the C standard; they're not extensions,
they're language features. (As far as I can tell, the name "C+"
hasn't been used, but of course you can use any name you like.)
I don't believe this would have any effect on the likelihood of your
features being adopted in a future C standard, if that's still your
goal. C has borrowed existing features from other languages before
(e.g., prototypes from C++).
Just to be clear, this is a completely serious suggestion.