aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2018-08-21 16:06:58 -0700
committerPaul Eggert2018-08-21 19:24:38 -0700
commitc79444c5b7b8ead1ea98ed5603bf2a49c13dbf16 (patch)
tree2b36ffd2d444b3fcbf0f6e59a8b4ca4ef69ba5f4
parentf8069952abf147d090032ad6b941a728cad2c496 (diff)
downloademacs-c79444c5b7b8ead1ea98ed5603bf2a49c13dbf16.tar.gz
emacs-c79444c5b7b8ead1ea98ed5603bf2a49c13dbf16.zip
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.
-rw-r--r--doc/lispref/objects.texi7
-rw-r--r--lisp/subr.el9
-rw-r--r--src/data.c21
3 files changed, 13 insertions, 24 deletions
diff --git a/doc/lispref/objects.texi b/doc/lispref/objects.texi
index 8c92de123c2..a0940032eee 100644
--- a/doc/lispref/objects.texi
+++ b/doc/lispref/objects.texi
@@ -190,9 +190,10 @@ but many machines provide a wider range.
190fixnum will return a bignum instead. 190fixnum will return a bignum instead.
191 191
192 Fixnums can be compared with @code{eq}, but bignums require 192 Fixnums can be compared with @code{eq}, but bignums require
193@code{eql} or @code{=}. The @code{fixnump} predicate can be used to 193@code{eql} or @code{=}. To test whether an integer is a fixnum or a
194detect such small integers, and @code{bignump} can be used to detect 194bignum, you can compare it to @code{most-negative-fixnum} and
195large integers. 195@code{most-positive-fixnum}, or you can use the convenience predicates
196@code{fixnump} and @code{bignump} on any object.
196 197
197 The read syntax for integers is a sequence of (base ten) digits with an 198 The read syntax for integers is a sequence of (base ten) digits with an
198optional sign at the beginning and an optional period at the end. The 199optional sign at the beginning and an optional period at the end. The
diff --git a/lisp/subr.el b/lisp/subr.el
index cafa4835eaf..9e880bc880e 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -366,6 +366,15 @@ was called."
366 (declare (compiler-macro (lambda (_) `(= 0 ,number)))) 366 (declare (compiler-macro (lambda (_) `(= 0 ,number))))
367 (= 0 number)) 367 (= 0 number))
368 368
369(defun fixnump (object)
370 "Return t if OBJECT is a fixnum."
371 (and (integerp object)
372 (<= most-negative-fixnum object most-positive-fixnum)))
373
374(defun bignump (object)
375 "Return t if OBJECT is a bignum."
376 (and (integerp object) (not (fixnump object))))
377
369(defun lsh (value count) 378(defun lsh (value count)
370 "Return VALUE with its bits shifted left by COUNT. 379 "Return VALUE with its bits shifted left by COUNT.
371If COUNT is negative, shifting is actually to the right. 380If COUNT is negative, shifting is actually to the right.
diff --git a/src/data.c b/src/data.c
index 4c6d33f2940..08c7271dd79 100644
--- a/src/data.c
+++ b/src/data.c
@@ -511,16 +511,6 @@ DEFUN ("integerp", Fintegerp, Sintegerp, 1, 1, 0,
511 return Qnil; 511 return Qnil;
512} 512}
513 513
514DEFUN ("fixnump", Ffixnump, Sfixnump, 1, 1, 0,
515 doc: /* Return t if OBJECT is an fixnum. */
516 attributes: const)
517 (Lisp_Object object)
518{
519 if (FIXNUMP (object))
520 return Qt;
521 return Qnil;
522}
523
524DEFUN ("integer-or-marker-p", Finteger_or_marker_p, Sinteger_or_marker_p, 1, 1, 0, 514DEFUN ("integer-or-marker-p", Finteger_or_marker_p, Sinteger_or_marker_p, 1, 1, 0,
525 doc: /* Return t if OBJECT is an integer or a marker (editor pointer). */) 515 doc: /* Return t if OBJECT is an integer or a marker (editor pointer). */)
526 (register Lisp_Object object) 516 (register Lisp_Object object)
@@ -598,15 +588,6 @@ DEFUN ("condition-variable-p", Fcondition_variable_p, Scondition_variable_p,
598 return Qt; 588 return Qt;
599 return Qnil; 589 return Qnil;
600} 590}
601
602DEFUN ("bignump", Fbignump, Sbignump, 1, 1, 0,
603 doc: /* Return t if OBJECT is a bignum. */)
604 (Lisp_Object object)
605{
606 if (BIGNUMP (object))
607 return Qt;
608 return Qnil;
609}
610 591
611/* Extract and set components of lists. */ 592/* Extract and set components of lists. */
612 593
@@ -4153,7 +4134,6 @@ syms_of_data (void)
4153 defsubr (&Sconsp); 4134 defsubr (&Sconsp);
4154 defsubr (&Satom); 4135 defsubr (&Satom);
4155 defsubr (&Sintegerp); 4136 defsubr (&Sintegerp);
4156 defsubr (&Sfixnump);
4157 defsubr (&Sinteger_or_marker_p); 4137 defsubr (&Sinteger_or_marker_p);
4158 defsubr (&Snumberp); 4138 defsubr (&Snumberp);
4159 defsubr (&Snumber_or_marker_p); 4139 defsubr (&Snumber_or_marker_p);
@@ -4179,7 +4159,6 @@ syms_of_data (void)
4179 defsubr (&Sthreadp); 4159 defsubr (&Sthreadp);
4180 defsubr (&Smutexp); 4160 defsubr (&Smutexp);
4181 defsubr (&Scondition_variable_p); 4161 defsubr (&Scondition_variable_p);
4182 defsubr (&Sbignump);
4183 defsubr (&Scar); 4162 defsubr (&Scar);
4184 defsubr (&Scdr); 4163 defsubr (&Scdr);
4185 defsubr (&Scar_safe); 4164 defsubr (&Scar_safe);