First page Back Continue Last page Summary Graphics
Typing (2)
Implicit static (invented in ML, 1977)
- find out variable and function types based on their use, eg:
- fact(x)= if x=0 then 1 else x*fact(x-1)
- x compared with 0 implies x is a int
- fact can return 1 implies fact returns a int
- This inference works nicely with complex programs
- pros:
- as good type checking as explicit static
- most of the expressivity of dynamic typing
- cons: sometimes type error messages don't occur where you would except
Notes: