[erlang-questions] Reassigning variables
Adam Kelly
cthulahoops@REDACTED
Wed Mar 18 00:51:49 CET 2009
2009/3/17 Matthew Dempsky <matthew@REDACTED>:
> I can do "throw {skip, Reason}", and match on just that, but that
> breaks when an underlying functions starts throwing exceptions of the
> form {skip, _}.
As I understand it throw is reserved for exceptions that are expected
to be caught. Ie, early returns from deeply nested functions and the
like. That is exactly this pattern, so you should be able to call
other bits of code without getting unexpected throws. Real errors
should use error or exit.
Looking through your parse transform code it strikes me how few
functions you are using. This is a functional programming language
and all the meat of your parse transform is in one function. I'm not
surprised that you keep wanting to reassign variables in this case.
This is my first refactoring pass and that transform_match_expr
function is still too long.
http://www.cthulahoops.org/reassign_pt.erl
In 20,000 lines of Erlang, I think I've used numbered variables once.
(And that needs refactoring!)
Adam.
More information about the erlang-questions
mailing list