emacs-devel
[Top][All Lists]
Advanced

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

Re: Using the GNU GMP Library for Bignums in Emacs


From: Paul Eggert
Subject: Re: Using the GNU GMP Library for Bignums in Emacs
Date: Fri, 6 Jul 2018 21:53:15 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

Tom Tromey wrote:

I was not sure what to do with calls like:

#define lisp_h_CHECK_FIXNUM(x) CHECK_TYPE (FIXNUMP (x), Qintegerp, x)

That last line should use Qfixnump, surely.

I ran this and got a big patch:

  sed -i 's/INTEGERP/FIXNUMP/g' *.[ch]
I doubt whether this is the best option. Often, the code should actually be checking for integers, not for fixnums. So the existing code needs to be examined more carefully, with only some INTEGERP instances changed to FIXNUMP. (Code should prefer INTEGERP to FIXNUMP, for generality, but in some cases FIXNUMP will have to do.)

  sed -i 's/make_number/make_fixnum/g' *.[ch]

This should be OK, at least for now. At some point we may want to have make_fixnum do proper overflow checking.

  sed -i 's/CHECK_NUMBER/CHECK_FIXNUM/g' *.[ch]

CHECK_NUMBER has always been a misnomer of course, since it excludes floats. But these uses need to be fixed by hand; some changed to CHECK_INTEGER, and others to CHECK_FIXNUM, depending on what check is wanted. In that sense this is like the INTEGERP/FIXNUMP issue.

I wasn't sure if I should try to rename NUMBERP or NATNUMP.
On the one hand they are really checking only for fixnums.
On the other hand, the logical names seem like they'd be unwieldy.

NUMBERP and NATNUMP should not exclude bignums, since their Lisp counterparts don't. If there is a need for "fixnum or float" (not that likely) or for "nonnegative fixnum" (more likely), I suggest the names FIXNUM_OR_FLOATP and FIXNATP.



reply via email to

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