Re: iolist_size/1 in guard tests

Michael Truog <[email protected]> Mon, 24 Jan 2022 12:51:29 -0800
Newsgroups gmane.comp.lang.erlang.general
Message-ID <[email protected]>
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