On Sep 30, 1:02 am, Paul Rubin <no.em...@nospam.invalid> wrote: > >> > > > 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. > > The second sentence is not disproved by a cast from one datatype to > > another (which changes the value) that happens before maximum() is called. > > int maximum(int a, int b); > > int foo() { > int (*barf)() = maximum; > return barf(3); > } > > This compiles fine for me. Where is the cast? Where is the error message? > Are you saying barf(3) doesn't call maximum?
With Tiny C on my system, your code does not cause maximum to give an incorrect value, or to blow up: int maximum(int a, int b) { printf("entering maximum %d %d\n",a,b); if ( a > b ) return a; else return b; } int foo() { int (*barf)() = maximum; return barf(3); } int main (int argc, char *argv[]) { printf("maximum is %d\n",foo()); } ------------- output ----------------------------------- entering maximum 3 4198400 maximum is 4198400 -- http://mail.python.org/mailman/listinfo/python-list