No subject

Sun Sep 19 15:01:13 UTC 2010

is some confusion about type systems, in particular strict
vs strong typing.

Type systems can basically be mapped onto two axes;

         dynamic ----------+---------- static

Strong type systems prevent you from doing things that do not make
sense like adding an integer and a list. For instance, in Python,

    >>> x = 1
    >>> y = [ 1 , 2 ]  
    >>> x + y

gives an error like "unsupported operand type(s) for +: 'int' and 'list'".

Weak type systems allow things that don't make sense (possibly with
a user provided type cast). For instance in C:

       float test (GLIst *list)
       {    int x = 10 ;
            return x + (int) list ;

the above makes no sense whatsoever, but the compiler accepts the 
programmers word that this is in fact what the programmer wants.

Purely static type systems are ones where all the types are checked at
compile time and the run time objects contain no type information
and no type checking is done at run time.

Purely dyanmic type systems are ones where every run time data
object carries around its type and all the type checking is done
at run time.

With the above axes set up you can have languages like C with
weak static types, Haskell with strong static types and Python
with strong dynamic types. I don't know of any language that
can really be said to have weak dynamic types.

Furthermore, most dynamically types languages have a small amount
of static type checking built in, but this is usually a by product
of syntax checking.

Similarly, in a statically typed langauge its possible to implement
a library with an object type where the type checking for operations
on those objects is carried out at run time.

Finally, many people assume that all strictly typed languages
require the programmer to explicitly define the types of everything.
Fortunately, this is not the case. There are a whole family of
languages that use Hindley-Milner type inference to infer the types
of all objects from the context. These languages include Ocaml and

Erik de Castro Lopo

More information about the Linux-audio-user mailing list