Python Strings
Erik Max Francis
max at alcyone.com
Wed Sep 6 14:31:57 EDT 2000
Keith Ray wrote:
> What most people mean by "strongly-typed" or "staticly typed" is
> "there
> is compile-time checking of variable types" (and parameter-types, and
> function-return-types and expressions being assigned or passed into
> variables/parameters/etc.).
>
> What most people mean by "weakly-typed" or "dynamically typed" is
> "there
> is only run-time checking of variable types" (and parameter-types, and
> function-return-types and expressions being assigned or passed into
> variables/parameters/etc.).
I think it would be a mistake to consider these pairs of words synonyms;
strongly typed vs. weakly typed and statically typed vs. dynamically
typed are two different (orthogonal) measures. Python is strongly
typed, but dynamically typed. Java or C++ is strongly typed and
statically typed. Perl, for instance, would be weakly typed and
dynamically typed.
Strong vs. weak typing has to do with how data types are managed; if the
same data is treated as different types in different contexts, then it's
weakly typed. Perl is an example, for instance, because $a = 1 can be
treated either as an integer or a string, depending on the context.
With weak typing the "types" of objects are contained in the operations
(in Perl, + is arithmetic addition, and . is string concatenation) that
are being performed on these weakly-typed objects, rather than in strong
typing where the type is an intrinsic property of an object (in Python,
1 is an int, but '1' is a string).
Your descriptions above are most accurately for static vs. dynamic
typing. Static typing means compile-time checking and variables of
fixed, pre-declared type; dynamic typing (or late binding) means
variables are simply untyped references to objects and that operations
and called methods determine at runtime what the type of their arguments
are.
--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/ \ After a thousand years or so you go native.
\__/ Camden Benares
Kepler's laws / http://www.alcyone.com/max/physics/kepler/
A proof of Kepler's laws.
More information about the Python-list
mailing list