Books of Note

Practical Common
LispThe best intro to start your journey. Excellent coverage of CLOS.

ANSI Common
LispAnother great starting point with a different focus.

Paradigms of Artificial Intelligence
ProgrammingA superb set of Lisp examples. Not just for the AI crowd.

Monday, November 05, 2007

Missing Bignums 

There was a day when I didn't know what a bignum was or why I would possibly want one. I was fat, dumb, and happy with basic fixed-precision integers in C and Java land. When I first started playing with Common Lisp, I thought, "Wow, that's a neat trick that I can actually evaluate (factorial 100) and it works correctly, but how often am I going to be doing that??"

Boy, was I wrong. I'm working on a project in Emacs Lisp in my spare time and I suddenly have a need to deal with integers that are greater than the anemic 29-bit fixnums that Emacs Lisp supports. While 29 bits might be okay for working with character positions in a buffer, it falls flat on its face whenever you want to manipulate anything from the outside world. In this case, 29 bits is too small to handle any 32-bit quantity, let alone some of the 64-bit stuff I want to deal with. I'm kind of amazed that RMS didn't just implement 32-bit boxed integers if he wasn't going to do full bignums.

I found that calc.el includes support for its own version of bignums and I might be forced to use those. Painful, though. I guess the old saying is true--you don't miss something until it's gone.

Does any Emacs guru know if bignums are being considered as a standard Emacs Lisp datatype for a future Emacs version? I'm currently working in Emacs 22.1 (Fedora 7). Given the release schedule of Emacs versions, any future support won't help me, but it would at least be comforting to know that other people see the same need.


Comments:


Don't hold your breath.

Calc is amazing, but I assume it's dog-slow for anything serious.
 


Rumour has it there are bignums in XEmacs, and SXEmacs apparently builds even further on that, but I don't believe there's anything in GNU Emacs. So you will probably have to stick with whatever calc.el does.
 


The latest XEmacs beta (21.5.18) has support for bignums thanks to the GMP library. You may want to give it a try.
 


The SXEmacs numeric types are pretty cool. It not only has arbitrary size integers (as many Lisp and Schemes have), but it has arbitrary precision floats as well.
 

Post a Comment


Links to this post:

Create a Link

This page is powered by Blogger. Isn't yours?