GNU bug report logs - #42147
28.0.50; pure vs side-effect-free, missing optimizations?

Previous Next

Package: emacs;

Reported by: Andrea Corallo <andrea_corallo <at> yahoo.it>

Date: Tue, 30 Jun 2020 22:28:02 UTC

Severity: normal

Found in version 28.0.50

Done: Mattias EngdegÄrd <mattiase <at> acm.org>

Bug is archived. No further changes may be made.

Full log


Message #214 received at 42147-done <at> debbugs.gnu.org (full text, mbox):

From: Mattias EngdegÄrd <mattiase <at> acm.org>
To: Andrea Corallo <akrl <at> sdf.org>
Cc: 42147-done <at> debbugs.gnu.org, Paul Eggert <eggert <at> cs.ucla.edu>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>,
 Andrea Corallo <andrea_corallo <at> yahoo.it>
Subject: Re: 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 <at> 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.





This bug report was last modified 4 years and 282 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.