[erlang-questions] Exceptions in guards are blocked. Why?
Richard O'Keefe
ok@REDACTED
Thu Jan 29 23:56:46 CET 2009
On 30 Jan 2009, at 2:14 am, Alexander Semenov wrote:
> Hi, folks,
>
> Can you explain me why exceptions are blocked in guards?
It is not that exceptions are *blocked* in guards,
but that they signify *failure*.
> For example I wrote this in erlang shell:
>
> F = fun(X) when (X == 0) or (X / 0 > 2) -> true; (_) -> false end.
Why did you write that rather than
F = fun (X) -> X == 0 orelse X/0 > 2 end
> Is this cause of 'side effects free' guards nature?
Not really. It's because guards aren't true or false;
they succeed or fail. (Blurring this distinction was a
really bad idea.)
More information about the erlang-questions
mailing list