What is a type error?

Marshall marshall.spight at gmail.com
Thu Jul 13 19:28:36 EDT 2006


Joe Marshall wrote:
> Marshall wrote:
> >
> > Consider the following Java fragment:
> >
> > void foo() {
> >   int i = 0;
> >   int j = 0;
> >
> >   // put any code here you want
> >
> >   j = 1;
> >   i = 2;
> >   // check value of j here. It is still 1, no matter what you filled in
> > above.
> >   // The assignment to i cannot be made to affect the value of j.
> >
> > }
>
> True, but you have hidden the pointers.  Semantically, the identifiers
> i and j refer not to integers but to locations that hold integers.  The
> assignment modifies the location.

What the implementation looks like shouldn't affect how we speak
of the logical model. In the above code, there are no pointers.

By your definition, "pointer" and "variable" are synonyms. That doesn't
seem like a good idea to me. (What if i and j end up in registers?
I have not heard it said that registers have addresses.)


> > Those two local primitive variables cannot be made to have the same
> > identity. But you can update them, so this is an example of mutability
> > without the possibility of identity.
>
> The identity is temporal:  You use the same variable name at two
> different times.  Do you intend for the second `i' to mean the same
> variable as the first `i'?

Okay, so "i" and "i" have the same identity. I suppose you could argue
that the language's namespace is an address-space, and variable names
are addresses. At this point, though, you've made the concept of
identity
so broad that it is now necessarily a property of all languages that
use
named values, whether updatable or not. I think you would also have
to call "3" a void pointer by this scheme.

Clearly there is *some* difference between a language which allows
explicit pointers and thus aliasing and one that doesn't. What term
would you use? First-class variables?


Marshall




More information about the Python-list mailing list