Getting started
James J. Besemer
jb at cascade-sys.com
Wed Sep 25 15:25:52 EDT 2002
Adam Taylor wrote:
> This last is available at:
> http://research.microsoft.com/Users/luca/Papers/TypeSystems.pdf
I believe your interpretation is accurate for the most part.
> Cardelli doesn't use the term "weakly typed" himself, but on page 5 he
> seems to be say that "weakly typed" is the commonly used term for what
> he calls "weakly checked". C is weakly checked, in his terminology, and
> that's why it's unsafe.
My read of page 5 is he equates his internal use of "weakly checked"
with "weakly typed" and further suggest that the latter term is commonly
used "in the literature," which it does seem to be.
> But people on this thread seem to be using "weakly typed" to mean
> roughly the same thing as Cardelli's "untyped". Which is fine, and
> pretty close to Cardelli's terminology. But clearly the terms "untyped"
> (=="weakly typed" on this thread) and "weakly checked" (=="weakly typed"
> in common usage) are very different things.
Well, some people here use the term casually and incorrectly, as a
measure of quality of a language's object model, which I am sure you'll
agree is completely inconsistent with most uses of the term, including
Cardelli's.
Interestingly, a google search on the term revealed that about 25% of
the meaningful hits equated "weakly typed" and "dynamically typed" (the
latter of which is what Cardelli calls "untyped"). The other 75%
generally characterized strong vs. weak type systems in terms of "type
safety", i.e., a mechanism for preventing "type errors," regardless of
whether the checking is done statically or dynamically. [The list of
references appears in a prior post to this thread.]
I think your read of Cardelli overall is correct -- that Python, like
Lisp, would be classified as "untyped" because it has no static type
system. A literal reading furthermore defines "weakly typed" only in
terms of static checking.
However, I submit that his use is inconsistent with the more common use
of the term. Too, I think this is actually a minor oversight in
Cardelli's paper. His focus overall was static systems and I think he
simply didn't give enough consideration to dynamically typed languages.
E.g., he says "untyped" languages such as Lisp can be "safe" but he
defines "weakly typed" only in terms of languages that do static type
checking. I would argue that in the first place he misclasifies Lisp as
"untyped". I suspect he took the naive view of Lisp, in which
everything is a list, when in fact a rather wide variety of "objects"
actually exist in a typical, mature Lisp system. Of course, Python and
Smalltalk are better examples, in that they both have robust object type
systems and are in principle very secure from a type checking sense.
(Of course, there are probably things you can do with the compiler and
debug class objects that violate type safety, making them both unsafe in
general.)
The primary distinction between safe and unsafe, strong and weak type
systems revolves around the notion of whether or not "type errors" can
be prevented by the type system. The distinction between typed and
untyped is less interesting, except to use "untyped" as a way to
eliminate a class of languages from further discussion. Within typed,
there should be two sub-classes, based on whether type checking is
primarily static or dynamic. This is more interesting and useful, and
is consistent with "the literature" as far as I can determine.
I furthermore have a conjecture that much of Cardelli's work on
"judgments" would apply equally well to static and to dynamic systems.
The important criterion is that the type system be secure and that the
total collection of function x arguments definitions be unambiguous (at
least during the sequence of computation of interest). Whether the
checks take place at compile time or at runtime I don't think materially
affects his theories. But I could be overlooking something in this regard.
In any case, my own use of the term "weakly typed" and associated terms
(strongly typed, type safety, etc.) in this thread have been consistent
with "the literature" (though slightly inconsistent with Cardelli), in
that I class Python to be "strongly typed" using "dynamic checking".
That seems to be the consensus here. Only confusion has been about
"weakly typed," and hopefully we're close to exhausting that topic..
--jb
--
James J. Besemer 503-280-0838 voice
2727 NE Skidmore St. 503-280-0375 fax
Portland, Oregon 97211-6557 mailto:jb at cascade-sys.com
http://cascade-sys.com
More information about the Python-list
mailing list