anything like C++ references?

Stephen Horne intentionally at blank.co.uk
Tue Jul 15 02:03:11 EDT 2003


On 15 Jul 2003 05:10:56 GMT, bokr at oz.net (Bengt Richter) wrote:

>On Tue, 15 Jul 2003 00:22:15 +0100, Stephen Horne <intentionally at blank.co.uk> wrote:
>[...]
>>>> 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.
>>>
>>>Syntactic sugar or no, they still behave differently than other
>>>datatypes and are therefore not consistent... IMHO.
>>
>>They behave exactly like pointers. You just use different notation to
>>get that behaviour. That is what makes them syntactic sugar.
>>
>BZZT. C++ references do not behave *exactly* like pointers. Try to make one
>point to a different place than it was initialized to point to.

You can't - at least not without very nasty hacks. But that doesn't
necessarily matter.

You could make a very strong case for references being a distinct
datatype from pointers, I'll admit. It depends whether you think of
the notation for operations being an aspect of the data type -
obviously the case in C++ programming, but I was thinking in terms of
mathematical abstract data types at the time.

Just because there is no notation to express an operation, doesn't
necessarily mean that operation doesn't exist ;-)





More information about the Python-list mailing list