[Top][All Lists]

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

Re: Using the GNU GMP Library for Bignums in Emacs

From: Stefan Monnier
Subject: Re: Using the GNU GMP Library for Bignums in Emacs
Date: Tue, 10 Jul 2018 23:16:05 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>> it's simpler to explain that there are just integers.
> Yes, and this is a significant win.

I'm not sure I understand why a return value of `bignum` for `type-of`
would complicate the doc.  AFAICT all it takes is:

    diff --git a/doc/lispref/objects.texi b/doc/lispref/objects.texi
    index b94de80b65..3ca5f6399f 100644
    --- a/doc/lispref/objects.texi
    +++ b/doc/lispref/objects.texi
    @@ -2034,7 +2034,7 @@ Type Predicates
     @defun type-of object
     This function returns a symbol naming the primitive type of
    address@hidden  The value is one of the symbols @code{bool-vector},
    address@hidden  The value is one of the symbols @code{bignum}, 
     @code{buffer}, @code{char-table}, @code{compiled-function},
     @code{condition-variable}, @code{cons}, @code{finalizer},
     @code{float}, @code{font-entity}, @code{font-object},

There's no need to explain the difference between `integer` and `bignum`
here, just like we don't explain the difference between `subr` and

> If interning bignums (so that eq works on them) is what it takes to satify
> Stefan's concerns, then I'm all for interning them. The idea is to avoid
> unnecessary distinctions between fixnums and bignums, so that Lisp
> programmers can focus on their problems rather than worry about integer
> representation. Although it's OK to have user-visible predicates fixnump and
> bignump for the few programmers who really need to know, I'm not seeing use
> cases for why these predicates should be any more special than characterp or
> natnump are.
> That's fine, but I was asking for use cases not implementation
> motivation. THat is, I was wondering why a Lisp programmer would want to use
> cl-generic that way. Having cl-generic distinguish fixnums from bignums
> sounds like more a solution looking for a problem than a truly
> useful feature.

I think I'm missing a reality check here.  We are talking about
`type-of`, right?  Have you looked at how many times it's used in Elisp?
It's a rather obscure function (and indeed the lispref recommends to
use predicates instead: type-of might be handy to implement other things
(like cl-generic) but is otherwise rather inconvenient to use).

So, yes, the motivation is thin because the decision will be irrelevant
in 99.99% of the cases.  If you're really dead-set on having it
hide the difference between fixnums and bignums, I won't oppose it.

I just mentioned my preference based on the fact that cl-generic is
(AFAIK) by far the most common user of `type-of` nowadays.


reply via email to

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