Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!columbia!read.columbia.edu!kearns From: kearns@read.columbia.edu (Steve Kearns) Newsgroups: comp.lang.c++ Subject: References considered crippled Message-ID: <6361@columbia.edu> Date: 14 Jun 89 00:07:18 GMT References: <9473@alice.UUCP> Sender: news@columbia.edu Reply-To: kearns@read.UUCP () Distribution: comp.lang.c++ Organization: Columbia University Department of Computer Science Lines: 34 I suspect this has already been discussed. If so, could someone summarize? I think that one should be able to assign to references. Here are some arguments for this idea. What were the decisions for making them unassignable? (arg 1: for) If references are just like pointers that are automatically dereferenced, then to provide the full functionality of a pointer it should be reassignable. (arg 2: against) There is no syntax available for assigning to a reference. If "int bill, frank; int& joe = bill", then "joe = 8" assigns 8 to bill, but does not change joe. (rebuttal) How about &joe = &frank? This makes sense, in that it says that the address of joe should be thought of as the address of frank; further it should be detectable by the compiler as an address of a reference on the lhs of an asssignment. (arg 3: for) The current functionality is upwardly compatible of this change. Right now a reference is constant. (arg 4: against) Knowing that something is an unchanging reference provides the compiler with useful optimizing possibilities. (rebuttal) The const keyword should be able to express a constant reference to something. As things stand now, I am forced to allocate extra references everytime I want to change one, which is inefficient in itself. (arg 5: against) References aren't needed at all since they are just a shorthand for a constantly dereferenced pointer. (rebuttal) c++ is just a shorthand for assembly language. but a useful one. -steve