[erlang-questions] Guards syntax for multiple values

Dan Sommers 2QdxY4RzWzUUiLuE@REDACTED
Wed Mar 27 02:04:43 CET 2019


On 3/26/19 7:07 PM, Richard O'Keefe wrote:
> Everybody seems to be chasing after how to express "X in [...]" as a guard
> without responding to the suggestion of copying SML/NJ's "or patterns" as
> Erlang has already copied andalso and orelse from SML.  "or patterns" do
> not introduce a newreserved word, do not make a special case of a function
> in a module other than erlang". and are strictly more general than "_ in _".

Speaking as a long time polyglot and a relative newcomer to
Erlang, here's my response:  the "or pattern" is already
used elsewhere to solve this problem, and fits Erlang's
functional style very well.  The "in" operator creates an
impedance mismatch.

Now that I understand some of the arguments against lists:
member/2, I would also favor a new erlang:list_member (or
similarly named function) over an "in" operator.  I've
written plenty of Python code, and "in" fits in over there,
but it's a bad fit for Erlang, and definitely not sexy
given the alternatives.

> I am also puzzled that nobody seems to be concerned that the one and only
> example we have of a use case is code that should never be written in the
> first place ...

I couldn't agree more.

Dan



More information about the erlang-questions mailing list