Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!mcsun!sunic!tut!tukki!sakkinen From: sakkinen@tukki.jyu.fi (Markku Sakkinen) Newsgroups: comp.lang.misc Subject: Re: An Interesting View of "Strong" Vs. "Weak" Typing Message-ID: <2653@tukki.jyu.fi> Date: 10 Jan 90 08:25:42 GMT References: <7049@tank.uchicago.edu> <16678@megaron.cs.arizona.edu> Reply-To: sakkinen@jytko.jyu.fi (Markku Sakkinen) SAKKINEN@FINJYU.bitnet (alternative) Organization: University of Jyvaskyla, Finland Lines: 38 In article <16678@megaron.cs.arizona.edu> gudeman@cs.arizona.edu (David Gudeman) writes: >In article <7049@tank.uchicago.edu> keith@curry.uchicago.edu (Keith Waclena) writes: > [...] >> [...] >>I would say that C is weakly typed (or untyped) dynamically, and >>strongly-typed (but not too strongly) statically... > >This last sentence bothers me. It would be quite simple to implement >a C operator such as "(typeof) x" that returns some representation of >the type of the variable x. Granted this operator _does_ have to >refer to the type information gathered at compile time (it probably >would be treated as a compile-time constant, like "(sizeof) x"), but >the type of x is still available at run-time. I think Waclena's original characterisation is accurate. Gudeman is thinking about what C could be if it was different! The semantics of C is very heavily based on the premise that there is no run-time descriptive information associated with any programme objects. So, if one extended C with a 'typeof' operator, an expression like "typeof *p" could only give the base type of p, _not_ the type of the object to which p points at run time. One reason why I do not consider C++ a good object-oriented language is that the above characterisation holds for C++ as well. Even it keeps no run-time type information except for the bare minimum needed to handle virtual functions. There _are_ strongly/statically typed languages that also have complete run-time type information and a 'typeof' operator. One example is the object-oriented language Mode, created by Juha Vihavainen at the University of Helsinki (vihavain@uhecs.helsinki.fi). Markku Sakkinen Department of Computer Science University of Jyvaskyla (a's with umlauts) Seminaarinkatu 15 SF-40100 Jyvaskyla (umlauts again) Finland