What is a type error?

Pascal Costanza pc at p-cos.net
Fri Jun 23 13:39:53 CEST 2006


Chris Smith wrote:
> Pascal Costanza <pc at p-cos.net> wrote:
>> What about this: You get a type error when the program attempts to 
>> invoke an operation on values that are not appropriate for this operation.
>>
>> Examples: adding numbers to strings; determining the string-length of a 
>> number; applying a function on the wrong number of parameters; applying 
>> a non-function; accessing an array with out-of-bound indexes; etc.
> 
> Hmm.  I'm afraid I'm going to be picky here.  I think you need to 
> clarify what is meant by "appropriate".

No, I cannot be a lot clearer here. What operations are appropriate for 
what values largely depends on the intentions of a programmer. Adding a 
number to a string is inappropriate, no matter how a program behaves 
when this actually occurs (whether it continues to execute the operation 
blindly, throws a continuable exception, or just gets stuck).

> If you mean "the operation will 
> not complete successfully" as I suspect you do, then we're closer...

No, we're not. You're giving a purely technical definition here, that 
may or may not relate to the programmer's (or "designer's") 
understanding of the domain.


Pascal

-- 
3rd European Lisp Workshop
July 3 - Nantes, France - co-located with ECOOP 2006
http://lisp-ecoop06.bknr.net/



More information about the Python-list mailing list