[Haskell-cafe] Haskell Propeganda

Dan Weston westondan at imageworks.com
Wed Aug 27 15:23:45 EDT 2008

Tim Docker wrote:
> David Roundy wrote:
>> Which illustrates the point that it's not type safety 
>> that protects us from segfaults, so much as bounds checking,
>> and that's got a non-trivial runtime cost.  At least, most
>> segfaults that *I've* caused (in C or C++) have been from
>> overwriting the bounds of arrays, and that's precisely the problem
>> that Haskell does *not* solve using its type system. 
> That differs from my experience. Most segfaults that *I've* caused (in
> C or C++) have been due to dereferencing null pointers. Type safety
> does help you here, in that Maybe lets you distinguish the types of
> things that are optionally present from those that must be. 
> Tim

Huh? Type safety buys you not having to worry about dereferencing stale 
nonnull pointers (lifetime of reference exceeding lifetime of referent), 
but nothing about dereferencing null pointers, which are the moral 
equivalent of Nothing.

Failure to handle a null pointer is just like using fromJust and results 
in the same program termination (undefined).


More information about the Haskell-Cafe mailing list