Mark Carter wrote:
The typical example in C is:
mem = malloc(1024)
Malloc returns 0 to indicate that memory cannot be allocated, or a
memory address if it can. The variable mem is a so-called hybrid
variable; it crunches together 2 different concepts: a boolean value
(could I allocate memory?) and an address value (what is the address
where I can find my allocated memory).
It's considered a bad idea because it makes it easy for programmers to
use the value inappropriately - witness the number of programmers who
pass in 0 as a memory location.
This is a bad idea in C, because you cannot force programmers to test
the return value properly.
The Maybe type in Haskell is a good idea, because you must test the
a Maybe value to extract the real value. (Using the Maybe monad this
can be hidden.)
-- Lennart
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe