Revision as of 16:55, 7 May 2012
The article contains this:
- Weak typing: There are only few distinguished types and maybe type synonyms for several types. E.g. C uses integer numbers for booleans, integers, characters, bit sets and enumerations.
- Strong typing: Fine grained set of types like in Ada, Wirthian languages (Pascal, Modula-2), Eiffel
This is not my understanding of strong and weak typing at all. I would like to replace it with:
- Strong typing: Objects have types, and there are no implicit conversions (although overloading may be used to simulate them), so using an object in the wrong context is an error. In Python, indexing an array with a string or float throws a TypeError exception; in Haskell it will fail at compile time.
However I lack any real authority to back up this definition. Comments appreciated.
I actually also find the definition of static/dynamic typing unsatisfactory. I'm not sure in this case what I would use instead, but IMO it's something about whether type errors arise according to the structure of a program, or according to its execution, e.g. the following Python is not a type error:
x = None + 1
This seems to be a more denotational definition than the somewhat arbitrary runtime/compile-time distinction.