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

From: Mattias Engdegård <[email-masked]>
Date: Wed, 8 Jul 2020 23:25:58 +0200

Hello Andrea,

> 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?

Ultimately it depends on the transformations you do, but yes: this patch substitutes let-bound names for their values, and since the behaviour of mutating string literals is undefined, it's safe. Consider:

(let ((s "abc"))
  (f s)
  s)

It doesn't matter what 'f' does; since it isn't permitted to mutate its argument string, the transformation to

(progn (f "abc") "abc")

is safe (assuming lexical binding, since f could otherwise set s to something else).

> 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?

Symbols are included, but since this is (normalised) Lisp source, plain symbols are variables; constants of symbol type are represented as (quote SYM), matched by the and-expression. Keywords are just symbols whose name begin with a colon, like :chocolate, and need no quoting.