[erlang-questions] Reassigning variables
Richard O'Keefe
ok@REDACTED
Wed Mar 18 04:26:18 CET 2009
On 18 Mar 2009, at 11:45 am, Matthew Dempsky wrote:
> Your example messes up if requested_ad_size, has_ads, or is_filtering
> throws an exception.
>
> 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, _}.
I don't _like_ using exceptions for control structures, but
that's another story. It _is_ possible to have an Erlang
function that catches precisely the throws you want it to.
You can create a reference, include that in the thrown terms,
and -- thanks to Erlang letting you use bound variables in
patterns -- also include it in the patterns. It's one more
line of code.
More information about the erlang-questions
mailing list