iolist_size/1 in guard tests

Michael Truog mjtruog@REDACTED
Mon Jan 24 21:51:29 CET 2022


On 1/4/22 11:05 AM, Aleksander Nycz wrote:
>
> is_map_key/2 -> O(log(N))
>
> so guard BIFs definition is:
>
> complexity < O(N) and side effect free?
>
The Erlang Language Specification describes guard expressions (at 
https://github.com/erlang/spec/blob/0d70db4d904c45678cb46de8f0f0f93eb35c66f3/src/es-notation.tex#L862-L867):
"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)."

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 https://github.com/erlang/otp/issues/5568

Best Regards,
Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20220124/a524c4c0/attachment.htm>


More information about the erlang-questions mailing list