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

From: Andrea Corallo <[email-masked]>
Date: Wed, 08 Jul 2020 19:14:43 +0000

Mattias Engdegård <[email-masked]> writes:

> +(defun byte-optimize--substitutable-p (expr)
> +  "Whether EXPR is a constant that can be propagated."
> +  ;; Only consider numbers, symbols and strings to be values for substitution
> +  ;; purposes.  Numbers and symbols are immutable, and mutating string
> +  ;; literals (or results from constant-evaluated string-returning functions)
> +  ;; can be considered undefined.
> +  ;; (What about other quoted values, like conses?)
> +  (or (booleanp expr)
> +      (numberp expr)
> +      (stringp expr)
> +      (and (consp expr)
> +           (eq (car expr) 'quote)
> +           (symbolp (cadr expr)))
> +      (keywordp expr)))

Hi Mattias,

in the branch I'm working I've a function similar in scope to this so
reading your patch this got my attention.

In my version I assumed (after a look to the manual) to have strings to
be immutable only at speed 3.  Is it safe to assume this always instead?

Also I wanted ask why symbols are not included but only keywords, is
this to respect the side effect of interning them or something else?

Thanks!

  Andrea

-- 
[email-masked]