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: Sat, 21 Apr 2018 09:08:03 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

Siraphob (Ben) Phipathananunth wrote:

Hopefully there isn't existing
Emacs Lisp code that relies on unsafe arithmetic /anywhere/.

I'm afraid your hope will be in vain....

And it depends on what we mean by "unsafe". Is it safe to assume that (eq (1+ 0) 1) returns t, for example? The Scheme standard says "no" but we might decide that 'eq' should "work" for fixnums in Emacs Lisp. That sort of thing.

If the functions + - * / operate on bignums (instead of dedicated bignum
functions), would that mean we drop 32/64 bit integers entirely?

No, it'd mean we'd still have fixnums vs bignums internally, and most programs wouldn't care whether an integer is represented via fixnum or bignum, as it'd be an issue merely of efficiency. Some programs would probably still care though (for efficiency reasons), and GNU Calc quite possibly would be one such program.

It would make much more sense to have separate math functions for 32/64
bit numbers and for bignums. In doing so, it should be obvious to the
Emacs Lisp programmer when to use what.

That's not how other Lisps work, by and large. They have just one integer type and one set of functions. The goal is to simplify the job of writing a program.



reply via email to

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