| > On Jul 2, 12:26 pm, Nick Keighley <
[email protected]>
| > wrote:
| >> Then it becomes an "ask Dennis Richie question". He designed the
| >> language and for some reason decided he didn't need references.
| >> C is a very small and simple language that is close to the machine,
| >> presumably references were just an abstraction that didn't seem
| >> necessary (if, indeed, anything like references was even considered).
| > yeah pointer to pointer could be replacement for reference to pointer
| > in C . I was thinking that in C++ , we have pointer to reference . I
| > was thinking what could be the reason why Denis has not put reference
| > support in C ..
|
| Pointers were in wide use when Dennis Richie created the C language. The
| same was not true of references. I am not 100% sure in saying so; but, I
| don't think any language was using references at the time.
Whether references were called "references or not", there were languages
that provided something similar. PL/I, for example, provided "based
variables". You could set a pointer to point to a string, for example.
Thereafter, everytime the pointer value was changed, the based variable
would acquire a new value, without any explicit deferencing being done as in
C. Here is an example:
TestProg: PROC OPTIONS(MAIN);
DCL Str char(20) init ("abcdefghijklmnopqrst");
DCL C char based (p),p pointer;
DCL i FIXED BIN(31);
p=addr(Str);
DO i=1 to 20;
put edit(C)(A(1)); p+=1;
end;
put skip;
END TestProg;
| C++ was my
| first exposure to references. Pointers predate references and references
| where created as a direct answer to some of the problems that can be
| created using pointers.
|
| Whether Dennis Richie would have used references had they been more well
| known is at this point academic.
|
| That C has not adoped references is more clear. Many languages move
| forward adding many new technologies to its core language. C++ itself has
| done this and it is a very different language then it was when I first
| started. The C community however, probably in a large account of us who
| tend to dislike what C++ turned out to be, has chosen to stay closer to
its
| roots and recognize itself as a separate language then just as the
| precursor to C++.