2 ms·
The thing is that in a safe language, a value always evaluates to a value of the type of the expression[1]. E.g. in Haskell, if a function returns a list: fo
by danieldk 14y ago
The thing is that in a safe language, a value always evaluates to a value of the type of the expression[1]. E.g. in Haskell, if a function returns a list:
foo :: Int -> [a]
It should always evaluate to a list. There is no such thing as a null pointer. The only thing that comes close to a nullable type is an option type such as Maybe:
data Maybe a = Just a | Nothing
The function
bar :: Int -> Maybe [a]
can either evaluate to a Just [a] or Nothing.
[1] Actually, I lied a bit, since there is bottom: http://www.haskell.org/haskellwiki/Bottom http://www.haskell.org/haskellwiki/Bottom But bottom does not fullfil the same role as, say null pointers.