"Strong typing vs. strong testing"

RG rNOSPAMon at flownet.com
Thu Sep 30 15:52:58 EDT 2010


In article 
<0390e2b4-fa28-49b3-a867-39be6d66828f at w19g2000yqb.googlegroups.com>,
 ImpalerCore <jadill33 at gmail.com> wrote:

> On Sep 29, 9:01 pm, RG <rNOSPA... at flownet.com> wrote:
> 
> <snip>
> 
> > [ron at mighty:~]$ cat foo.c
> > #include <stdio.h>
> >
> > int maximum(int a, int b) { return a > b ? a : b; }
> >
> > int main() {
> >   long x = 8589934592;
> >   printf("Max of %ld and 1 is %d\n", x, maximum(x,1));
> >   return 0;}
> >
> > [ron at mighty:~]$ gcc -Wall foo.c
> > [ron at mighty:~]$ ./a.out
> > Max of 8589934592 and 1 is 1
> 
> In the context of procedural programming, there is always an implicit
> contract between the function and its client.  If you're going to fool
> around sending cleverly crafted garbage into the input of 'maximum'
> due to C conversion rules, why do you expect the 'maximum' function to
> be responsible for producing the correct response to an ill-formed
> question?  What alternative behavior of 'maximum' would you prefer to
> see, that the C language auto-promote the function arguments and
> return type to type long based on the type of arguments provided to
> the 'maximum' function?
> 
> You either learn to play in the sandbox that C provides, splinters and
> all, or you find another sandbox.
> 
> Best regards,
> John D.

You're missing a lot of context.  I'm not trying to criticize C, just to 
refute a false claim that was made about it.

rg



More information about the Python-list mailing list