Static Typing in Python
donn at u.washington.edu
Thu Mar 18 01:46:23 CET 2004
In article <tyfn06f87xj.fsf at lxplus059.cern.ch>,
Jacek Generowicz <jacek.generowicz at cern.ch> wrote:
> JCM <joshway_without_spam at myway.com> writes:
> > The FOLDOC definition
> > http://wombat.doc.ic.ac.uk/foldoc/foldoc.cgi?query=weak+typing
> > which mentions things like
> > int a = 5;
> > float b = a;
> > to me doesn't have anything to do with weak typing, since the int is
> > correctly converted to a float. I guess thay're calling it "weak
> > typing" because the cast is implicit.
> Yes, and the more implicit type conversion a language does, the more
> likely it is to get it wrong (because what is correct depends on the
> programmers intention), therefore there is a greater likelyhood of
> getting the wrong result. Which is why I consider implicit type
> conversions to be an aspect of weak typing. (However, I have no
> problems with you not seeing it that way.)
> If you don't call it "strong/weak typing", do you have an alternative
> name to describe differences in how "easy going" a type system is?
> Consider the following table.
> ML Python PERL
> 1.5 + 1 No Yes Yes
> "3" + 3 No No Yes
> ML is clearly stricter than Python, which is stricter than PERL. Do
> you have a name for this sort of strictness ?
I say "strong" as in "strong static typing". Don't say "strict",
because "ML is a strict language" doesn't say anything about
its type system, it's about order of evaluation. Haskell is
non-strict, but has strong static typing.
Speaking of which, Haskell's type system supports type classes
like Num (number), where Int and Float are instances of Num
that implement its "+" function. I'm probably leaving out a
paragraph or two of the interesting parts, but the end result
is that 1.5 + 1 works. Haskell is not weakly typed.
Donn Cave, donn at u.washington.edu
More information about the Python-list