[erlang-questions] Exceptions in guards are blocked. Why?
Fri Jan 30 13:00:55 CET 2009
On Fri, 2009-01-30 at 11:56 +1300, Richard O'Keefe wrote:
> 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
I wrote this only as example, since Joe's book says, that such a guard
fails but nothing was said about what does it mean "fail". Thank you for
> > 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.)
Alexander Semenov <>
More information about the erlang-questions