[erlang-questions] Guards syntax for multiple values

Eckard Brauer eckard.brauer@REDACTED
Tue Mar 26 21:41:36 CET 2019

Hello Dániel,

thanks for the clarification. See the problems.

Best regards / üdvözölök

Am Tue, 26 Mar 2019 20:37:43 +0100
schrieb Dániel Szoboszlay <dszoboszlay@REDACTED>:

> You are right that a parser could easily distinguish "X in Y" from
> "M:in(...)" or even "fun M:in/N" based on the context. The problem,
> as I see it, is that "X in Y" introduced a new infix operator to the
> language, while "is_member(X, Y)" does not, it is syntactically just
> an ordinary function call.
> The first problem with introducing a new operator is that there are
> some conventions for operators in Erlang. Like every alphabetic
> operator is currently a reserved word. So we either break this
> convention with "in", or we make "in" a reserved word that would
> break all the existing "M:in(...)" use cases. I like neither of these
> options.
> The second problem I see with a new operator is that it would require
> an update of every tool that parses Erlang code. An Erlang parser is
> very likely to have a hard-coded list of operators (together with
> e.g. the precedence order of them), and wouldn't just try to parse
> any atom as a potential infix operator. On the other hand, a parser
> may have a hard-coded list of BIF-s that are allowed in a guard, but
> that's not likely. Most probably it would just accept any function
> call in a guard position, so going with "is_member/2" or
> "lists_member/2" would not break a typical parser.
> Cheers,
> Daniel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: Digitale Signatur von OpenPGP
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190326/969a3090/attachment.bin>

More information about the erlang-questions mailing list