On Sun, 16 Feb 2003 15:14:02 +0900 Jim Weirich <jweirich / one.net> wrote: <snip> > Actually, I would say C is weakly typed because it is easy to > accidently interpret data as the wrong type ... especially in pre-ANSI > C (without prototypes). I'm not sure... is it weakly typed just because you can lie to it? ;) C types are basically just a promise as to the size. If you break your promise, it's not really the compiler's fault. However, I don't think that's the case here: > For example ... > > One file contains ... > > extern int f(); IIRC, in K&R C (and ANSI too), () makes a default int parameter. This also happens to be the result of no prototype. > int main () { > f(3.1416); > } This should just be demoted to int by the compiler. <snip> > Unions are also problematic, although in that case you expect problems > so accidents are less likely. <snip> Well, if we're going by matz's "interchangeable" definition, C is only "sort-of" weak typing, because what happens is fully determinate at compile time. You can do weird things which can prove useful: struct A { int a, b, c, d; }; int main() { struct A a; int *ptr = (int*)&a; int i; for(i = 0; i < 4; i++) *(ptr + i) = i; } ...but it's arguable whether interchanging and lying to the compiler are the same thing. ;-) For instance, a fairly black-and-white case of interchangeable types is numbers and strings in Perl or PHP. They can (mostly) be interchanged. Odd things sometimes happen at boundary conditions (like 0), but "123" + 456 results in 579. Telling the gullible compiler that my &a is an int* works, but it's me treating one thing in two ways, not the compiler treating two things in one way. I say they're all just numbers, so there's nothing to do differently anyway... which brought up the one-type question in another reply. -- Ryan Pavlik <rpav / users.sf.net> "Spinal hazards *are* hazardous..." - 8BT