2 ms·
> In an imperative language, can I write a map or filter whose argument is guaranteed to be pure? Of course. See, e.g. Java's checked exceptions. If you marked
by pron 11y ago
> In an imperative language, can I write a map or filter whose argument is guaranteed to be pure?
Of course. See, e.g. Java's checked exceptions. If you marked every effectful function as throwing a checked exception, the compiler can enforce which effects are allowed.
> Can you easily convince the type system that an imperative loop will indeed terminate? [Without supplying anything even vaguely resembling a proof.] With pattern matching and recursion, the compiler can check whether recursive calls are always passed smaller arguments.
Model checkers can do this just as well.
> What does this even mean?
That programs aren't required to be 100% correct, just as they aren't required to be as fast as possible. It is perfectly acceptable for most programs to fail on rare edge cases. If there is an inverse relationship between the manifestation of the bug in the frequency of the circumstances that causes it, then you're fine (put simply: it's OK to fail with ever higher probability on ever rarer cases).