Erlang Type System

Thomas Lindgren <>
Sun Sep 18 11:54:54 CEST 2005



---  wrote:

> I was hoping someone could clear up some confusion. 
> As I understand 
> it, with a dynamically typed language you can change
> the type of x.  
> For instance in Python x = 1; x = 1.5;  Obviously we
> can't do that in 
> Erlang.  So is that a proper idea of what dynamic
> typing is, and does 
> this make Erlang statically typed or dynamically? 
> Most people tell me 
> Erlang is still dynamically typed because the
> variable passed in a 
> function can be of any type.

Dynamic typing usually means that the system checks
type correctness dynamically, at runtime, rather than
statically, at compile time.

In languages like Erlang, Lisp, Prolog, Smalltalk, ...
all values/objects/terms have an associated type,
which can be inspected at runtime. As an example, the
Erlang VM thus checks that the inputs to "+" are
numbers when the call to + occurs, and performs the
appropriate sort of addition (integer add, bignum add,
float add, conversion if needed). In the same vein,
Smalltalk dynamically looks up the code for a method
name when a send occurs; and so on. (If the types are
wrong, an exception is raised.)

Best,
Thomas



	
		
______________________________________________________ 
Yahoo! for Good 
Donate to the Hurricane Katrina relief effort. 
http://store.yahoo.com/redcross-donate3/ 




More information about the erlang-questions mailing list