[comp.lang.misc] Re^2: An Interesting View of "Strong" Vs. "Weak" Typing

chl@cs.man.ac.uk (Charles Lindsey) (01/12/90)

throopw@sheol.UUCP (Wayne Throop) writes:

>I try nowadays not to use the terms "strongly typed" or "weakly typed",
>because so many people mean so many things by them.  If I had to state
>what they meant to me, I'd say something like

>    Strongly typed languages are those languages where the correspondence
>    between typed values and the operations the programmer intends to allow
>    on those typed values can be made known to the language system, and
>    weakly typed languages are those languages where this correspondence
>    must be managed by the programmer. 

Oh Dear! Wayne really has got it all mixed up! Here is the definition that I
give to my students, and which I had always understood to convey the general
consensus.

In a strongly-typed language, the rules of the language ensure that
	a) Every value has a type;
	b) The type {of the value} yielded by every expression is statically
	determinable at compile time;
	c) Every context where an expression can occur (e.g. the RHS of
	assigments, actual-parameters of calls) has the type which it accepts
	statically determinable at compile time.

Clearly, this implies that strong typing is a static property of interest at
"compile" time (or "parse" time if there is no compiler), but that the
distinction between values and containers (or between imperative and
functional programming) is irrelevant). Under this definition, ALGOL 68, ADA,
SML and Miranda are all strongly typed, and PASCAL almost makes it (those
worries about mususe of variants, you know).

>Under {Wayne's} definition of "strong" and "weak" types, I'd say that C is a
>somewhat strongly typed language which is often used as a somewhat
>weakly typed language by people who take advantage of the traditional
>lack of diagnostic messages produced by the traditional language
>processors for the language. 

No way!. C, like FORTRAN, is weakly typed because, although values clearly
have types, there are too many ways to break (quite legally) through the
protection. But a C compiler can legitimately complain at some type faults,
hence it is at least "weak".

There are also languages, such as SETL and Lisp, which are not even weakly
typed, but in any such language the possibility of runtime checking (with the
aid of suitable tags) is always available.