plt/racket — pull request #851 by gus-massa (2014-12-16 20:46:17+00:00)
Title: Removes dead code after errors in begin forms

This is only a draft, but it works and passes all the test cases.

It removes all the dead code after an error in the `begin` forms, i.e. reduces `(begin x (error 'e) y) ==> (begin x (error 'e)) `. It only detect "explicit" errors generated by calls to `error`, `raise-user-error`, ...

I'd like to extend this to other kind of errors like wrong argument number of known functions. Also I'd like to extend this to other types of expressions, in particular `if`, and eventually to all of them.

But first I'd like some advice and feedback about the implementation. The details to cut the `begin` forms were more difficult than I expected, in spite it's a trivial straightforward case :).

I submitted two alternative implementations. One carries the error until it's detected, and the other clears the error before optimizing each expression.

I'm also not sure how to handle correctly expressions like `(begin (error 'e) (fl+ x y))` because after the reduction it's transformed to `(error 'e)` that doesn't look like a `flonum?` any more.