Define `pi' in elisp, even with bigfr. (Closes bug #176)
authorSteve Youngs <steve@sxemacs.org>
Mon, 21 Dec 2015 23:35:21 +0000 (09:35 +1000)
committerSteve Youngs <steve@sxemacs.org>
Mon, 21 Dec 2015 23:35:21 +0000 (09:35 +1000)
An elisp constant defined with #'defconst can be let-bound, or otherwise
altered.  But one that is defined in C cannot be.  SXEmacs' pi is
sometimes defined in elisp, and sometimes in C, depending on whether it
has bigfr or not.  The Calc XEmacs package let-binds pi in a couple of
places, resulting in errors when (featurep 'bigfr) => t.

With this change, pi is defined in elisp regardless of bigfr.  But it will
still use bigfr to obtain the value if it is available.

* lisp/float-sup.el: Define pi in elisp, even if we have bigfr,
and in that case set it to what mpfr gives us.
Same for e.

* src/ent/ent-mpfr.c (init_ent_mpfr): Vpi -> Vbigfr_pi
(vars_of_ent_mpfr): Vpi -> Vbigfr_pi, pi -> bigfr-pi

* src/ent/ent-mpfr.h: Vpi -> Vbigfr_pi

Signed-off-by: Steve Youngs <steve@sxemacs.org>
lisp/float-sup.el
src/ent/ent-mpfr.c
src/ent/ent-mpfr.h

index 05dace0..964c408 100644 (file)
     (error "Floating point was disabled at compile time"))
 
 ;; define pi and e via math-lib calls. (much less prone to killer typos.)
-(unless (featurep 'bigfr)
+(if (featurep 'bigfr)
+    (progn
+      (defconst pi bigfr-pi "The value of Pi (3.1415926...)")
+      (defconst e euler "The value of e (2.7182818...)"))
   (defconst pi (* 4 (atan 1)) "The value of Pi (3.1415926...)")
   (defconst e (exp 1) "The value of e (2.7182818...)"))
 
index 7214800..dbca26a 100644 (file)
@@ -35,7 +35,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 \f
 Lisp_Object Veuler;
 Lisp_Object Veuler_mascheroni;
-Lisp_Object Vpi;
+Lisp_Object Vbigfr_pi;
 
 bigfr ent_scratch_bigfr;
 static ase_nullary_operation_f Qent_mpfr_zero, Qent_mpfr_one;
@@ -1599,8 +1599,8 @@ void init_ent_mpfr(void)
        Veuler_mascheroni = make_bigfr(0.0, 2048UL);
        mpfr_const_euler(XBIGFR_DATA(Veuler_mascheroni), GMP_RNDN);
 
-       Vpi = make_bigfr(0.0, 2048UL);
-       mpfr_const_pi(XBIGFR_DATA(Vpi), GMP_RNDN);
+       Vbigfr_pi = make_bigfr(0.0, 2048UL);
+       mpfr_const_pi(XBIGFR_DATA(Vbigfr_pi), GMP_RNDN);
 }
 
 void syms_of_ent_mpfr(void)
@@ -1620,7 +1620,7 @@ void vars_of_ent_mpfr(void)
        /* just some dummy values atm, to make the dumper smile */
        Veuler = make_int(1L);
        Veuler_mascheroni = make_int(1L);
-       Vpi = make_int(1L);
+       Vbigfr_pi = make_int(1L);
 
        DEFVAR_CONST_LISP("euler", &Veuler /*
 The value of Euler's constant e (2.7182818...).
@@ -1628,7 +1628,7 @@ The value of Euler's constant e (2.7182818...).
        DEFVAR_CONST_LISP("euler-mascheroni", &Veuler_mascheroni /*
 The value of the Euler-Mascheroni constant (0.5772156...).
                                                                 */);
-       DEFVAR_CONST_LISP("pi", &Vpi /*
+       DEFVAR_CONST_LISP("bigfr-pi", &Vbigfr_pi /*
 The value of pi (3.1415926...).
                                     */);
 
index 30e7b5f..143bd08 100644 (file)
@@ -41,7 +41,7 @@ extern Lisp_Object Qbigfrp;
 
 extern Lisp_Object Veuler;
 extern Lisp_Object Veuler_mascheroni;
-extern Lisp_Object Vpi;
+extern Lisp_Object Vbigfr_pi;
 
 \f
 typedef struct Lisp_Bigfr Lisp_Bigfr;