Subject: Re: bug#42147: 28.0.50; pure vs side-effect-free, missing optimizations?

From: Mattias Engdegård <[email-masked]>
Date: Sat, 25 Jul 2020 23:00:33 +0200

25 juli 2020 kl. 22.11 skrev Philipp Stephani <[email-masked]>:

> The manual states that
> "This function [concat] always constructs a new string that is not
> ‘eq’ to any existing string" so I don't see how it could ever be pure.

Actually that part of the manual was corrected fairly recently, as that statement hasn't been true for decades.

More to the point, the current set of functions marked as 'pure' are really the superset 'pure-absent-mutation': functions that are pure when it can be assumed that the arguments are not modified. This assumption can be based on physical immutability (integers), by convention (string constants), or anything else the compiler can prove such as control flow.

There is also the question of what equality to use and here the answer is probably 'equal' since we are only dealing with immutables. (The return values of these functions cannot be considered mutable for obvious reasons, so make-string is out.)

If you want to rename the property accordingly then I won't object. In any case, it is certainly a good idea to be precise about what the various sets really mean.

There are also some functions declared 'pure' that appear to have side effects: kbd, package-get-version