unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: Pip Cet <pipcet@gmail.com>, Emacs developers <emacs-devel@gnu.org>
Subject: Re: Bug#38708: eq vs eql in byte-compiled code
Date: Thu, 2 Jan 2020 18:26:29 +0100	[thread overview]
Message-ID: <613F0F55-EE3E-4A19-9A02-A0CC34172B13@acm.org> (raw)
In-Reply-To: <22304b46-55df-578d-7ce5-97c8b60f684e@cs.ucla.edu>

2 jan. 2020 kl. 09.38 skrev Paul Eggert <eggert@cs.ucla.edu>:

> [...] If it's not
> important, then I'd say the flonum/bignum deduplication patch is not urgent
> enough to put into Emacs 27.

Yes, we'd better leave Emacs 27 alone, except for improved documentation.

I'm feeling queasy about hash-consing floats and bignums. Benchmarking is treacherous in several regards: there is currently very little use of bignums for obvious reasons, and Emacs sessions are famously long-lived. The real problem is Emacs's archaic non-generational GC.

Most bignums aren't very big; they tend to obey a power law. Particularly common are full-word integers, just a bit or two larger than fixnums. They crop up in various kind of system interfaces (IDs, handles, addresses etc), FFIs, checksums/hashes, fields in binary files and protocols, and so on. Having bignums, we may see quite a few of these.

In other words, making bignums/flonums slower may seem to have no bad effects, until suddenly it has.

> The manual already says this:
> 
> To test numbers for numerical equality, you should normally use
> @code{=} instead of non-numeric comparison predicates like @code{eq},
> @code{eql} and @code{equal}.

That sentence mentions eq and eql as equally inferior alternatives to =, which isn't necessarily helpful.

> I found that a bit too dogmatic about avoiding eq on numbers, as it's reasonable
> to use eq in many cases (I do it in my code, you do it in your code, and as long
> as you know what you're doing it's OK).

We should be allowed to make recommendations as long as it's made clear that experts (ahem) can do what they please, no? The user may otherwise not realise that using eql instead of eq (1) makes their code more portable, and (2) extends it to a greater range of input data, both of which will make it useful in a wider range of circumstances.

That said, your patch is fine! One sentence, though:

> +If they were computed separately but happen to have the same value
> +and the same non-fixnum numeric type, then they might or might not be
>  the same object, and @code{eq} returns @code{t} or @code{nil}
>  depending on whether the Lisp interpreter created one object or two.


The "computed separately" qualifier is a bit too vague, but the statement also risks becoming too strong. Can't we just say that equal non-fixnum numbers may or may not be eq?





  reply	other threads:[~2020-01-02 17:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=613F0F55-EE3E-4A19-9A02-A0CC34172B13@acm.org \
    --to=mattiase@acm.org \
    --cc=eggert@cs.ucla.edu \
    --cc=emacs-devel@gnu.org \
    --cc=pipcet@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).