The real question is why should they? They didn't implement classes or templates, either. =P
Why should they? Because its syntactically cleaner. Why settle for typing more shit when you can simplify it.
Its not a fundamental change so I do not see the strawman argument of why not implement classes and templates while we are at it.
Changing it to C++ syntax lets the compiler "do the work for you" so you are not really changing the language itself that much.
C++ has its built in "& argument" feature to implement reference parameters for the programmer. The short story is, append an '&' to the type of a parameter, and the compiler will automatically make the parameter operate by reference for you. The type of the argument is not disturbed by this — the types continue to act as they appear in the source, which is the most convenient for the programmer.
From what I understand and read there is no concept of a reference type in C++ aswell. In both languages you pass the pointers to the called function, difference being that in C++ the compiler automatically hides the complete pointer definition details away from you. This is from what I read.
That's subjective. One could argue that references add ambiguity to syntax since the syntax for interacting with them is the same as intereacting with normal variables. More ambiguity != cleaner.
(not that I agree with that statement, though I certainly understand that viewpoint)
Its not a fundamental change
It really is. It's adding a whole new kind of variable. That's a very significant change.
But really.. the bottom line is... C is not C++. If you like C++ features (like references), then use C++.
If you don't like that C doesn't have those features, then don't use C.
void foo(int & a)
{
...
a=1;
...
}
int main()
{
int a;
foo(a);
}
Compiler detects called function accepts a pointer. Substitutes in it int *a
Compiler detects that same variable a and replaces it with *a.
Finally the compiler detects caller funcion and substitus &a instead of a.
I personally see that as the only change that needs to be made. If there are very deep fundamental changes to be made, then the simple question is: what are they? And until you present to me these underlying changes, you, sir, will have to clarify me on this:
You mean to tell me if Ritchie was stoned in '69 and made his assignment operator to be =**= and C++ revised it to =, you would be sitting here telling me, "well if you dont like C, use C++?"
Some problems do arise from the multiple uses of the same terms in Computer Science and languages. For instance a pointer is a reference to an object but it is not the same as a reference in C++. The when you talk about pass by reference, you are talking about passing a C++ reference into a function.
How about: http://en.wikipedia.org/wiki/Reference_(C%2B%2B)
Edit:
C has pointer types.
C++ has pointer and reference types (they are not the same).
You're basically saying "why doesn't C implement X feature that I like?".
I look at that question from the other perspective: "why should C implement X feature?".
This hasn't really been answered. All you said was "it's cleaner", but that's not really true. It adds a level of ambiguity:
1 2 3 4 5
int foo = 0;
func(foo); // does this modify foo?
// in C: no
// in C++, maybe. it's ambiguous. You'd need to see func's prototype
In C++, with the addition of things like classes, templates, operator overloading, etc, the use of references has additional benefits when coupled with those other features. So those benefits outweigh the ambiguities.
the other thing to realise is that C99 has nothing to do with C++03 (and I doubt C++11). How C develops is not influenced by C++ development, they only have a common ancestor.
Why settle for typing more shit when you can simplify it.
If you're coding in pure C, then you're obviously a masochist. C programmers welcome, if not love typing more than necessary. Adding a pass by reference feature to C would infuriate those programmers to the point of forcing them to migrate to assembler in protest.