anything like C++ references?

Tim Peters tim.one at comcast.net
Mon Jul 14 19:55:38 EDT 2003


[Stephen Horne]
> ...
> C++ references are tellingly also called self-dereferencing pointers.
> They are not a distinct concept - they are syntactic sugar. I suspect
> they mainly arise out of the modern desire to disguise pointers and
> fantasize that they're not there, though they certainly work very well
> in certain contexts.

You don't have to guess -- Stroustrup's "The Design and Evolution of C++"
explains his design rationales in detail.  Section 3.7 is devoted to C++
references.  The short course is that references were thought necessary to
support usable operator overloading; see the book for concrete examples; a
later "What Could and Should Have Been Different?" section explains why C++
references are a wart, but a pragmatically desirable wart.

About "modern desire", the earliest computer languages didn't expose
pointers at all (Lisp, COBOL, and Fortran are the prime early examples of
this).  Language exposure of machine addresses came in with lower-level
systems-programming languages (of which C is the prime example today).






More information about the Python-list mailing list