[erlang-questions] Questions on match specifications

Daniel Dormont <>
Sat Nov 12 05:29:01 CET 2011


Erlang also has reserved words. If I were revising the manual, I would
modify section 2.3 to explicitly say "or if it is a reserved word"
with a link to the list of reserved words, which includes both 'and'
and 'andalso'.

This has nothing to do with match specs specifically; as already
mentioned, there's a typo in that part of the manual. But in fact, you
cannot use 'and' or 'andalso' unquoted *anywhere* in Erlang if you
want them to be literal atoms rather than operators.

dan

On Fri, Nov 11, 2011 at 9:21 PM, wrp <> wrote:
> Thanks. That clear things up some. But I'm not sure about this one:
>
> On Nov 11, 6:44 am, Magnus Henoch <>
> wrote:
>> > 1. Quoting seems incosistent. Why is 'and' quoted but andalso is not?
>>
>> Probably a typo.  Both need to be quoted, otherwise you get a syntax
>> error.
>
> In the MatchConditions and MatchBody, aren't all the terms passed as
> atoms?
>
> Here are all the functions listed as allowed for ETS matches:
>
>        abs       is_atom       is_record      '=:='     'and'
>        element   is_binary     is_reference   '=/='     'or'
>        hd        is_constant   is_seq_trace   '=='      'not'
>        length    is_float      is_tuple       '/='      'xor'
>        node      is_function   '+'            '<'       'band'
>        round     is_integer    '-'            '=<'      'bor'
>        size      is_list       '*'            '>'       'bnot'
>        tl        is_number     'div'          '>='      'bxor'
>        trunc     is_pid        'rem'          andalso   'bsl'
>        self      is_port                      orelse    'bsr'
>
> According to the Erlang rules for atoms, "An atom should be enclosed
> in single quotes (') if it does not begin with a lower-case letter or
> if it contains other characters than alphanumeric characters,
> underscore (_), or @", so only the non-alphanumeric operators should
> need quoting. Why do the arithmetic and logical operators need to be
> quoted?
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list