latent-type-system


Languages with latent type systems, such as Scheme, contain no type declarations in the source code of programs. The "static" type scheme of a given program in such a language is thus latent: terms in the program may be considered to have types, but they aren't explicitly declared. It may be possible to infer types for terms in such programs, but it isn't necessarily easy to do so automatically, and there are usually many possible type schemes that can be assigned to a given program.

Usually, such languages use what are known as "dynamic types" (arguably, a misnomer) to keep track of the types of values at runtime, i.e. values are tagged with type tags so that e.g. strings can be distinguished from integers at runtime.

However, latent type systems are not the same as dynamic types, even though both are typically found together in the same language. The term "latent type" refers to the types of terms in the program, i.e. a syntactic concept, whereas "dynamic types" refer to the types of values at runtime.

One way to see the distinction here is to look at the type of a simple procedure:

   (define double (lambda (x) (* x 2))) 

The latent type of this procedure can be described as number -> number. However, the dynamic type of the procedure would usually be considered to be determined by the type predicates it satisfies: in this case, since (procedure? double) returns #t, we would say that the dynamic type of double is procedure.

This distinction is also the reason that type theorists say that "dynamic type" is a misnomer. Internal tags such as the one which identifies double as a procedure at runtime are used to help manage types, but the tags themselves do not correspond directly to types in many cases.


category-learning-scheme