[erlang-questions] Questions on match specifications

wrp <>
Sat Nov 12 03:21:44 CET 2011


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?



More information about the erlang-questions mailing list