Erlang Type System
Richard A. O'Keefe
Sun Sep 18 22:38:10 CEST 2005
As I understand it, with a dynamically typed language you can
change the type of x.
That is not a correct understanding.
For instance in Python x = 1; x = 1.5;
But in that example, nothing changed its type.
1 was and remained an integer.
1.5 was and remained a floating-point number.
A more accurate statement would be that in a dynamically typed language
"type" is a property of values rather than variables.
Obviously we can't do that in Erlang.
There are actually several senses in which you can.
Each process has a process dictionary, which is in practice
a hash table, and you can associate any kind of data with any
key and you can change the kind of data associated with an existing key.
Once you leave the realm of primitive scalar types, Java is arguably
a dynamically typed language, or at least was until 1.5.
Most people tell me Erlang is still dynamically typed because
the variable passed in a function can be of any type.
Either "most people" are confused, or you are mis-reporting them.
You cannot pass a variable to a function in Erlang.
Since Erlang does not associate types with variables at compile time,
it clearly isn't a statically typed language. Since it has values of
distinct and distinguishable types and has type-specific operations,
it isn't an untyped language either. What's left?
More information about the erlang-questions