Move bignump, fixnump from C to Lisp

* doc/lispref/objects.texi (Integer Type): Mention
most-negative-fixnum and most-positive-fixnum as alternatives
to fixnump and bignump.
* lisp/subr.el (fixnump, bignump): Now written in Lisp.
* src/data.c (Ffixnump, Fbignump): No longer written in C,
as these new functions are not crucial for performance.
This commit is contained in:
Paul Eggert 2018-08-21 16:06:58 -07:00
parent f8069952ab
commit c79444c5b7
3 changed files with 13 additions and 24 deletions

View file

@ -190,9 +190,10 @@ but many machines provide a wider range.
fixnum will return a bignum instead.
Fixnums can be compared with @code{eq}, but bignums require
@code{eql} or @code{=}. The @code{fixnump} predicate can be used to
detect such small integers, and @code{bignump} can be used to detect
large integers.
@code{eql} or @code{=}. To test whether an integer is a fixnum or a
bignum, you can compare it to @code{most-negative-fixnum} and
@code{most-positive-fixnum}, or you can use the convenience predicates
@code{fixnump} and @code{bignump} on any object.
The read syntax for integers is a sequence of (base ten) digits with an
optional sign at the beginning and an optional period at the end. The

View file

@ -366,6 +366,15 @@ was called."
(declare (compiler-macro (lambda (_) `(= 0 ,number))))
(= 0 number))
(defun fixnump (object)
"Return t if OBJECT is a fixnum."
(and (integerp object)
(<= most-negative-fixnum object most-positive-fixnum)))
(defun bignump (object)
"Return t if OBJECT is a bignum."
(and (integerp object) (not (fixnump object))))
(defun lsh (value count)
"Return VALUE with its bits shifted left by COUNT.
If COUNT is negative, shifting is actually to the right.

View file

@ -511,16 +511,6 @@ DEFUN ("integerp", Fintegerp, Sintegerp, 1, 1, 0,
return Qnil;
}
DEFUN ("fixnump", Ffixnump, Sfixnump, 1, 1, 0,
doc: /* Return t if OBJECT is an fixnum. */
attributes: const)
(Lisp_Object object)
{
if (FIXNUMP (object))
return Qt;
return Qnil;
}
DEFUN ("integer-or-marker-p", Finteger_or_marker_p, Sinteger_or_marker_p, 1, 1, 0,
doc: /* Return t if OBJECT is an integer or a marker (editor pointer). */)
(register Lisp_Object object)
@ -598,15 +588,6 @@ DEFUN ("condition-variable-p", Fcondition_variable_p, Scondition_variable_p,
return Qt;
return Qnil;
}
DEFUN ("bignump", Fbignump, Sbignump, 1, 1, 0,
doc: /* Return t if OBJECT is a bignum. */)
(Lisp_Object object)
{
if (BIGNUMP (object))
return Qt;
return Qnil;
}
/* Extract and set components of lists. */
@ -4153,7 +4134,6 @@ syms_of_data (void)
defsubr (&Sconsp);
defsubr (&Satom);
defsubr (&Sintegerp);
defsubr (&Sfixnump);
defsubr (&Sinteger_or_marker_p);
defsubr (&Snumberp);
defsubr (&Snumber_or_marker_p);
@ -4179,7 +4159,6 @@ syms_of_data (void)
defsubr (&Sthreadp);
defsubr (&Smutexp);
defsubr (&Scondition_variable_p);
defsubr (&Sbignump);
defsubr (&Scar);
defsubr (&Scdr);
defsubr (&Scar_safe);