next up previous contents
Next: 5.2.2 Canonicalization Up: 5.2 More About Types Previous: 5.2 More About Types

5.2.1 More Types Meaningful

Common Lisp has a very powerful type system, but conventional Common Lisp implementations typically only recognize the small set of types special in that implementation. In these systems, there is an unfortunate paradox: a declaration for a relatively general type like fixnum will be recognized by the compiler, but a highly specific declaration such as (integer 3 17) is totally ignored.

This is obviously a problem, since the user has to know how to specify the type of an object in the way the compiler wants it. A very minimal (but rarely satisfied) criterion for type system support is that it be no worse to make a specific declaration than to make a general one. Python goes beyond this by exploiting a number of advantages obtained from detailed type information.

Using more restrictive types in declarations allows the compiler to do better type inference and more compile-time type checking. Also, when type declarations are considered to be consistency assertions that should be verified (conditional on policy), then complex types are useful for making more detailed assertions.

Python ``understands'' the list-style or, member, function, array and number type specifiers. Understanding means that:

For related information, see section 5.11 for numeric types, and section 5.10.3 for array types.



Raymond Toy
Mon Jul 14 09:11:27 EDT 1997