bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Mattias Engdegård
Subject: bug#42147: 28.0.50; pure vs side-effect-free, missing optimizations?
Date: Thu, 9 Jul 2020 12:20:34 +0200

9 juli 2020 kl. 00.19 skrev Andrea Corallo <akrl@sdf.org>:

> Or is it maybe that the only way to certainly have a mutable string is
> with `copy-sequence' or `make-string'?

Yes; since the need for a mutable value is very unlikely, creating a fresh copy 
every time just in case would be a big waste of resources. Otherwise, we could 
only 'optimise'

 (concat "abc" "def")

to

 (copy-sequence "abcdef")

which would be a very modest improvement, for very little gain.

The two functions you mentioned are indeed guaranteed to return fresh, mutable 
strings and thus cannot be marked 'pure'.

String mutation is something of a special case: it is rare, yet its mere 
possibility incurs costs even for code that doesn't use it. Better try to keep 
that cost to a minimum.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]