[erlang-questions] Guards syntax for multiple values

Björn Gustavsson bjorn@REDACTED
Tue Mar 26 09:41:10 CET 2019


On Tue, Mar 26, 2019 at 9:08 AM Loïc Hoguin <essen@REDACTED> wrote:

> What about compiler trickery, as mentioned earlier in the thread? Either
> allowing 'lists:member(Var, <list literal>)' or 'Var in <list literal>'
> and rewriting this at compile time as a more verbose series of =:= tests
> and/or separate clauses? This would fit a lot of use cases.

Yes, that would work. As long as the list is a literal, the compiler
can rewrite it in a smarter way to reduce the complexity to O(log(N)),
which would be acceptable.

As José pointed out, all guard BIFs are currently in the Erlang
module. So most likely there would be a new guard BIF in the erlang
module called is_member/2 or lists_member/2.

/Björn

-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list