[erlang-questions] (newbie) Using Functions as Guards in Erlang
Jachym Holecek
jachym.holecek@REDACTED
Fri Jun 13 10:35:34 CEST 2008
On Fri, 13 Jun 2008 08:25:29 +0200, Doug Edmunds <dougedmunds@REDACTED>
wrote:
> check out the discussion on
> http://wrongnotes.blogspot.com/2007/09/little-erlang.html
>
> "The solution is to call the function and store it in a
> variable before we use it in the guard conditions."
Yes, but it's a solution to the particular case you hit
working with if/case/fun; not to the general inability
to use custom functions in guards.
Clearly, you can't "store it in a variable" when you're
at toplevel context (which is what Fuad has been asking
about) or when the object you'd like to inspect comes
from the pattern immediately preceding the guard.
-- Jachym
More information about the erlang-questions
mailing list