"Strong typing vs. strong testing"

Seebs usenet-nospam at seebs.net
Thu Sep 30 12:01:22 EDT 2010


On 2010-09-30, RG <rNOSPAMon at flownet.com> wrote:
> We lost some important context somewhere along the line:

>> > > in C I can have a function maximum(int a, int b) that will always
>> > > work. Never blow up, and never give an invalid answer. If someone
>> > > tries to call it incorrectly it is a compile error.

> Please take note of the second sentence.

I did.  That is entirely correct.

> One way or another, this claim is plainly false.  The point I was trying 
> to make is not so much that the claim is false (someone else was already 
> doing that), but that it can be demonstrated to be false without having 
> to rely on any run-time input.

It is not at all obvious to me that it is, in fact, false.  So far as
I can tell, *if* the function is successfully called, then it will take
two integers, compare them, and return the larger one.  It will never
return something which is not an integer.  It will never raise an exception.
It will never return a value which, if you try to treat it as an integer,
raise an exception.

Now, if you pass the wrong values to it, you will get wrong answers -- but
that's your problem for passing it wrong values.

I would understand an "invalid" answer to be one of the wrong category.  For
instance, if I have a function in Python that I expect to return a string,
and it returns None, I have gotten an answer that is "invalid" -- it's not
a string.

-s
-- 
Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nospam at seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.



More information about the Python-list mailing list