Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mcnc!rti!sheol!throopw From: throopw@sheol.UUCP (Wayne Throop) Newsgroups: comp.lang.misc Subject: Re: C strongly typed? Summary: by steven Pemberton's definition, pretty much so Message-ID: <0501@sheol.UUCP> Date: 10 Mar 90 23:49:49 GMT References: <849@enea.se> <8960013@hpfcso.HP.COM> <8881@boring.cwi.nl> Lines: 41 > From: steven@cwi.nl (Steven Pemberton) > I use "strongly typed" for: to what extent > does the compiler disallow illegal operations on values at > compile-time. A reasonable position. I largely agree. > Examples of 'illegal operations' are: indexing a non-array or > selecting a field from a non-structure, dereferencing a non-pointer, > assigning incompatible types, and so on. C passes all of these examples. On the other hand, I wouldn't call these "illegal", or the other examples Steven gives. They could be made "legal" by a language standard. Perhaps they ought to be called "imoral"? "Unethical"? Whatever... perhaps "surprising" would suffice. > The fact that languages only check certain subsets of all possible > illegal operations allows you talk in terms of degrees of strong > typing: certain languages are weakly typed, others are strongly typed; Right. Very good feature of this definition. > Examples of operations that could be reduced to compile-time type > errors are: dereferencing nil, array indexing errors and sub-range > errors in general. Well, since dereferencing nil is a sort of range check, I suppose that it could be checked for at compile time as easily as the others. But it seems to me that all of these can be reduced to solving the halting problem. Even if I'm wrong about that, the problem is quite a bit beyond the current state of the art of static flow-of-control analysis, is it not? ANYway, based on Stephen's definition, I'd say that C is fairly strongly typed compared to other Algol relatives, but that most people simply don't run the static checking phase of the compiler. -- Wayne Throop ! mcnc!rti!sheol!throopw or sheol!throopw@rti.rti.org