anything like C++ references?

Adam Ruth owski at hotmail.com
Mon Jul 14 14:35:57 EDT 2003


Stephen Horne <intentionally at blank.co.uk> wrote in message news:<7dc4hvslh7a8fk9p6cvsfqa1c8d44rmmnv at 4ax.com>...
> On 13 Jul 2003 21:03:59 -0700, owski at hotmail.com (Adam Ruth) wrote:
> 

> C++ has precisely one type of variable. That variable is a placeholder
> for a value of a datatype which is specified in the declaration. The
> datatype may be a pointer datatype, but so what? Pointer datatypes are
> not treated any differently than other datatype except that they, like
> all datatypes, they have their own set of functionality.

Granted.  Pointers are no different than other data types, but they
are typically used for operations that are semantically very different
than other datatypes are used for.  In that sense, they are, at a high
level, different data types.

It's like how c programming is taught has having pass by reference and
pass by value, when there is only pass by value at the implementation
level.  Pass by reference is a concept added on top of the language.
 
> 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.

> Funny thing. When I use algebra, the variables I define don't end up
> referring to different values, functions or whatever unless I
> explicitly redefine them. When I write a definition on one piece of
> paper, the things I wrote earlier on another sheet don't change.
> 
> Seems to me that the math equivalent of assignment (defining named
> things) works very much like the 'static language definitions' as you
> put it.

The devil is in the details.  Math assignment is static assignment is
dynamic assignment.  They really are all the same thing at a high
level, but it's the implementation and the subtleties that make them
vary.

Adam Ruth




More information about the Python-list mailing list