[erlang-questions] Don't understand the error message: call to local/imported function ... is illegal in guard

Guilherme Andrade g@REDACTED
Mon Dec 24 10:45:46 CET 2018


Only certain built-in functions may be used in if clauses, function guards,
case clause guards, and so on. They are listed under 'Expressions'[1], on
the reference manual.

What I believe you would like to do is usually achieved using case
expressions, which allow the evaluation of regular function calls. 'If'
clauses are uncommon nowadays and it's rare for them to be considered more
appropriate than the equivalent case clause or function head pattern.

[1]: http://erlang.org/doc/reference_manual/expressions.html#guard-sequences

On Mon, 24 Dec 2018 at 00:26, Donald Steven <t6sn7gt@REDACTED> wrote:

> This code works:
>
>      AlphaNumericChar = isAlphaNumeric(C),
>      if AlphaNumericChar ->
>
> but this code (which is functionally identical):
>
>      if isAlphaNumeric(C) ->
>
> produces an error message: call to local/imported function
> isAlphaNumeric/1 is illegal in guard
>
> Why?
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>


-- 
Guilherme
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20181224/ff889c9d/attachment.htm>


More information about the erlang-questions mailing list