What is a type error?

Chris Smith cdsmith at twu.net
Thu Jul 13 18:22:17 EDT 2006


Darren New <dnew at san.rr.com> wrote:
> Chris Smith wrote:
> > Unless I'm missing your point, I disagree with your disagreement.  
> > Mutability only makes sense because of object identity (in the generic 
> > sense; no OO going on here). 
> 
> Depends what you mean by "object".
> 
> int x = 6; int y = 5; x = y;
> 
> I'd say x was mutable, with no "identity" problems involved?

The variable x definitely has identity that's independent of its value.  
Some might call that a problem in and of itself, as it complicates the 
formal model of the language and makes it difficult to predict what 
result will be produced by normal order evaluation.

On the other hand, this thread seems to be using "identity" to mean 
"identity with potential for aliasing", in which case it is vacuously 
true that eliminating identity also prevents the problems that arise 
from aliasing.  It is true, and I agree on this with Marshall, that 
eliminating the potential for aliasing solves a lot of problems with 
checking invariants.  I also see, though, that the majority (so far, I'd 
say all) of the potential uses for which it's worth introducing mutation 
into an otherwise mutation-free language allow the possibility of 
aliasing, which sorta makes me wonder whether this problem is worth 
solving.  I'd like to see an example of code that would be harder to 
write without mutation, but which can obey any restriction that's 
sufficient to prevent aliasing.

> Why is it problematic that variables have identity and are mutable? 
> Certainly I can later "find" whatever value I put into x.

I simply found the language confusing.  I said it would be nonsensical 
for a language to have mutation without identity.

-- 
Chris Smith - Lead Software Developer / Technical Trainer
MindIQ Corporation



More information about the Python-list mailing list