Yoshiki Hayashi <yoshiki(a)xemacs.org> writes:
Hrvoje Niksic <hniksic(a)arsdigita.com> writes:
> > 1. Do pepole want bignum support?
>
> How are you planning to add it? Is (* 1000000 1000000) just going to
> work?
Yes.
Cool. Normally I wouldn't even ask this, but experiences with Python
and Java teach us that you never know how someone might choose to
implement fixnums.
> * XINT_FIXNUM: convert fixnum to integer, argument must be
fixnum.
> * XINT_COERCE_FIXNUM: convert fixnum or bignum to integer, but throw
> * XINT_ANY: convert fixnum or bignum to a C object that represents
Not really. If index ((point) etc.) is not allowed to have
bignum representable as integer, XINT_COERCE_FIXNUM is not
necessary.
So you plan to disallow any bignums smaller or equal to
most-positive-fixnum? That never crossed my mind, probably due to
exposure to Python.
I don't think people want to do something like (make-string (* 2
most-positive-fixnum) ?a)
You're probably right. In the general case, something like that might
be desirable because it would allow us to lower the fixnum size
without visible penalty. (Why would we want that? Perhaps to
reintroduce small conses.)
Every XINT will need to have one more check to signal better error
when argument is bignum.
You mean CHECK_INT, right? XINT does no error checking.
Every XINT in numeric functions will be converted to
something similar to XINT_ANY. But my sample implementation
doesn't convert everything into bignum. If arguments are
all fixnum and the result fits in fixnum range, all
operations are performed as fixnum.
I see. Here it would be nice to have compiler support for that, so
that the compiler can generate fixnum-only opcodes where it can prove
that fixnums are used. But that's not really possible without lexical
scoping, so we can forget it.
I guess the all-fixnum check is not too expensive, especially since
all these functions already check whether their arguments are numbers,
etc. With a little cleverness, the all-fixnum case might remain as
fast as it is now.
I think fixnum operations won't slow down much except a few more
check for bignum and a few more function call (you won't be able to
call just + in C).
Of course.
OK, you've convinced me. Your bignum plan makes sense and I would
very much like to see bignums in XEmacs.