<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body>
<div class="moz-cite-prefix">On 1/4/22 11:05 AM, Aleksander Nycz
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:a6801b4e-9e25-2581-9a9d-4c1c3f780757@comarch.pl">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<p><span class="code">is_map_key/2 -> O(log(N))</span></p>
<p><span class="code">so guard BIFs definition is:</span></p>
<p><span class="code">complexity < O(N) and </span><span
class="code">side effect free?</span></p>
</blockquote>
The Erlang Language Specification describes guard expressions (at
<a class="moz-txt-link-freetext" href="https://github.com/erlang/spec/blob/0d70db4d904c45678cb46de8f0f0f93eb35c66f3/src/es-notation.tex#L862-L867">https://github.com/erlang/spec/blob/0d70db4d904c45678cb46de8f0f0f93eb35c66f3/src/es-notation.tex#L862-L867</a>):<br>
"The guard tests and their constituent guard expressions (syntactic
category GuardExpr) have been chosen so that they are independent of
the state (i.e., their result depends exclusively on their
arguments), have no side effect and (with a few exceptions) take
O(1) time (with respect to the size of their arguments)."<br>
<br>
The main current problem is that erlang:node/0 contradicts this
because it is a guard function that isn't referentially
transparent. There currently are no plans to fix this long-term
problem based on the discussion at
<a class="moz-txt-link-freetext" href="https://github.com/erlang/otp/issues/5568">https://github.com/erlang/otp/issues/5568</a><br>
<br>
Best Regards,<br>
Michael<br>
</body>
</html>