"Strong typing vs. strong testing"

Keith Thompson kst-u at mib.org
Thu Sep 30 17:26:38 CEST 2010


RG <rNOSPAMon at flownet.com> writes:
[...]
> You can't have it both ways.  Either I am calling it incorrectly, in 
> which case I should get a compiler error, or I am calling it correctly, 
> and I should get the right answer.  That I got neither does in fact 
> falsify the claim.  The only way out of this is to say that 
> maximum(8589934592, 1) returning 1 is in fact "correct", in which case 
> we'll just have to agree to disagree.

You are calling maximum() incorrectly, but you are doing so in a way
that the compiler is not required to diagnose.

If you want to say that the fact that the compiler is not required
to diagnose the error is a flaw in the C language, I won't
argue with you.  It's just not a flaw in the maximum() function.

If I write:

    const double pi = 22.0/7.0;
    printf("pi = %f\n", pi);

then I suppose I'm calling printf() incorrectly, but I wouldn't
expect my compiler to warn me about it.

If you're arguing that

    int maximum(int a, int b) { return a > b ? a : b; }

is flawed because it's too easy to call it incorrectly, you're
effectively arguing that it's not possible to write correct
code in C at all.

-- 
Keith Thompson (The_Other_Keith) kst-u at mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"



More information about the Python-list mailing list