On Sep 29, 9:01 pm, RG <rnospa...@flownet.com> wrote:

<snip>

> [...@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;}
>
> [...@mighty:~]$ gcc -Wall foo.c
> [...@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.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to