PEP 285: Adding a bool type

Huaiyu Zhu huaiyu at gauss.almadan.ibm.com
Tue Apr 9 13:47:08 EDT 2002


Donn Cave <donn at u.washington.edu> wrote:
>Quoth Erik Max Francis <max at alcyone.com>:
>|
>| Weak typing usually refers to the idea that operations, not the objects
>| themselves, decide as what types to manipulate objects.  Dynamic typing
>| indicates that variables (or bindings) do not have an intrinsic type.
>
>At best that seems confusing to me.  It would seem to say that
>languages that use type inference would be weakly typed - they
>sure let the operations decide object type.  In Objective Caml:
>
>  # let oneup x = x + 1;;
>  val oneup : int -> int = <fun>
>
>  (i.e., because parameter x appears in the expression x + 1, x must
>   have type int, and the function result must also be of type int.)
>
>But Objective Caml's typing is hardly "weak" in any useful sense of
>the word, rather it's quite rigorous.

The types are uniquely associated with objects.  They are just not specified
explicitly.  The system infers, but not decides, what they are, using clues
from the operations.

The basis of type inference is that each object has exactly one type.

In contrast, in a weakly typed system, the _same_ object can have multiple
types.   In a hyperthetical example

		4 add 2  ===> 6
		4 concat 2  ===> 42

In such systems type inference in the style of functional languages is
impossible, since the type inferred in one context is not guaranteed to be
valid in another.

So I'd venture a claim that any language that is capable of type inference
is necessarily strongly typed.

Huaiyu



More information about the Python-list mailing list