[erlang-questions] Guards syntax for multiple values

Björn Gustavsson bjorn@REDACTED
Tue Mar 26 08:53:05 CET 2019


On Mon, Mar 25, 2019 at 7:03 PM Jesper Louis Andersen
<jesper.louis.andersen@REDACTED> wrote:
> Thinking out loud, I think it might be beneficial to look at two additions:
>
> lists:member - because length(..) is in the set of Valid GuardSeqs and is O(n)

lists:member/2 has always been problematic because it's O(n). The way
guard and guard BIFs are implemented (for efficiency), guard BIFs
can't yield during execution.

In OTP 22 we finally fixed that issue by implementing special
instructions for executing length/1:

https://github.com/erlang/otp/pull/2053

Because of the effort required to make length/1 yielding, it is
unlikely that we will ever introduce another guard BIF with O(n) or
worse complexity.

/Björn


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



More information about the erlang-questions mailing list