Hacker News new | ask | show | jobs
by giornogiovanna 2337 days ago
Well, Haskell calls the empty list the "null" list (see List.null), so I could say that List.head crashes when it encounters a null. :P

Anyway, the real lesson is that even if your language has sane defaults that force you to check that your list isn't empty, or that your pointers aren't null, a bad library function like List.head can hide that check away from you and crash anyway, bringing you back to square one in terms of the type system preventing unexpected crashes.

1 comments

The null works with cons. So it's not a proper null. A proper null should throw an exception if you try to do any operation on it.