| The term "strongy typing" has become ambiguous is recent years.
Aho & Ullman give the following definition:
... Other languages (such as Pascal) have many types but
the type of every name and expression must be calculable
at compile time. Such languages are said to be strongly
typed.
Clearly, by this definition, PL/I is a strongly typed language. However,
the most common use of the term outside the literature has to do with the
languages rigidity or flexibility at mixing types and the term is used to
describe the degree of rigidity in mixed-typed contexts. Thus Pascal is
said to be more strongly typed than PL/I.
Which is the right definition? I'm not sure that can be answered.
db
|
| Here are definitions I would give based on the way that I have seen the
terms used.
Untyped languages (Bliss, BCPL) - In these languages, the operations
determine how the data is to be interpreted. For example, if
A and B are data objects and the interpretation is based on
whether I perform FLOATING_ADD(A,B) or INTEGER_ADD(A,B).
Weakly typed languages (C, PL/I, FORTRAN) - In these languages, the
combination of the operator and the operand determines how the
data is to be interpreted. In addition, some checking is typically
performed to make sure that the operation and operand are "type
compatable", i.e. that you aren't doing something like trying to do
an indirection using a floating point number. The important point
about "weak" typing versus strong typing is mainly whether or not
the language allows you to use objects in a form other than their
original form without programmer-specified conversions. For example
C will allow you to assign a character constant to an integer (i = 'c'),
and full PL/I allows you to do things like use string concatenation
on 2 floating point numbers (s = 4.5 || 2.3). Structures of different
sizes and/or characteristics may be assignment compatable due to implicit
conversions.
Strongly typed languages (Pascal, Modula-2, Algol-60) - In these langauges,
all but a very small number of conversions (typically integer to
floating point) must be explicitly specified by the programmer. Data
structures are not considered assignment compatable unless they are
defined to have the same "base type". i.e. arrays cannot be assigned
unless they have the same base type and extents, and structures often
must be name-compatable, not just structurally compatable.
|