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 #35 received at 42147 <at> debbugs.gnu.org (full text, mbox):

From: Mattias EngdegÄrd <mattiase <at> acm.org>
To: Andrea Corallo <andrea_corallo <at> yahoo.it>
Cc: Paul Eggert <eggert <at> cs.ucla.edu>, Stefan Monnier <monnier <at> iro.umontreal.ca>,
 42147 <at> debbugs.gnu.org
Subject: Re: bug#42147: 28.0.50; pure vs side-effect-free, missing
 optimizations?
Date: Thu, 2 Jul 2020 16:51:03 +0200
2 juli 2020 kl. 15.56 skrev Andrea Corallo <andrea_corallo <at> yahoo.it>:

> Well is cons allocation a semantically visible effect then?  How is it
> different?

Conses are mutable and thus each have their own identity. Numbers are immutable and have none; there is no defined way to distinguish two numbers that have the same value ('eq' does not give well-defined results). The compiler is free to, and does, deduplicate equal bignums. For instance, try

(disassemble (lambda () (list 18723645817263338474859 18723645817263338474859)))

and you will see that the resulting code will only contain one instance of the number.

> I thought the reason why cons is not constant folded is to respect the
> allocation side effect, at least that's what I convinced my-self of :)

Yes, in the sense that

 (defun f () (cons 'a 'b))

produces a fresh (a . b) each time (f) is called, because the returned values can be distinguished both explicitly by 'eq' and by mutating it and observing whether the change affects previously returned values or not. Neither works for numbers.





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.