unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Bug#38708: eq vs eql in byte-compiled code
@ 2019-12-31 15:07 Pip Cet
  2019-12-31 15:51 ` Andrea Corallo
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Pip Cet @ 2019-12-31 15:07 UTC (permalink / raw)
  To: emacs-devel; +Cc: mattiase, eliz

Bug#38708 (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=38708)
concerned a recent change to deduplicate floating point and bignum
constants in the bytecode constants vector (when compiling with or
without optimization). There was some discussion on the bugs list,
which I'll attempt to summarize here:

The previous behavior was that if

(defun f () (format "%S %S" 1.0 1.0))

was compiled, the result would have a constant vector with two
separate, distinguishable entries for 1.0.

The new behavior is that if the same function is compiled, a single
constant is generated and referenced twice.

My initial objection to the patch, and the reason I would prefer not
to see it installed on the Emacs 27 branch, is that the apparent
behavior of eq will change in ways that seem paradoxical at first.

For example, this code will produce t:

(defun my-eq (a b) (eq a b))
(defun f () (xor (eq 1.0 1.0) (my-eq 1.0 1.0)))
(byte-compile 'f)
(f)

The reason for this is that (eq 1.0 1.0) is optimized to nil before
the constants are deduplicated, but other function calls use the
deduplicated values.

All this is related to, but not the same as, the debate over whether
eq and eql should be equivalent or not. Making them equivalent would
avoid such apparently paradoxical behavior once and for all, but it
would probably incur a significant runtime cost.

Another option might be to deduplicate constants before optimizing
forms such as (eq 1.0 1.0). That would be more work, but would also
avoid the problem.

Any thoughts?



^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2020-01-25  0:59 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-31 15:07 Bug#38708: eq vs eql in byte-compiled code Pip Cet
2019-12-31 15:51 ` Andrea Corallo
2019-12-31 16:05 ` Mattias Engdegård
2019-12-31 17:38 ` Paul Eggert
2020-01-01 12:38   ` Mattias Engdegård
2020-01-02  8:38     ` Paul Eggert
2020-01-02 17:26       ` Mattias Engdegård
2020-01-04 19:55         ` Stefan Monnier
2020-01-22 10:56       ` Mattias Engdegård
2020-01-25  0:59         ` Paul Eggert
2020-01-01 15:45   ` Stefan Monnier
2020-01-02  7:52     ` Paul Eggert
2020-01-02 12:27       ` Pip Cet
2020-01-02 23:12         ` Paul Eggert
2020-01-02 13:48       ` Eli Zaretskii
2020-01-04 18:54       ` Stefan Monnier
2020-01-04 19:33         ` Paul Eggert
2020-01-04 19:49           ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).