guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

1+ and 1- in C


From: Kevin Ryde
Subject: 1+ and 1- in C
Date: Mon, 11 Apr 2005 08:17:00 +1000
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3 (gnu/linux)

I propose to do 1+ and 1- in C so they're as fast as plain + and -.
Calling scm_sum and scm_difference will still get goops/generics
dispatch the same as the scheme code, if I'm not mistaken.

--- numbers.c.~1.277.~  2005-03-13 11:17:05.000000000 +1100
+++ numbers.c   2005-04-10 09:31:40.000000000 +1000
@@ -4107,6 +4107,16 @@
 }
 
 
+SCM_DEFINE (scm_oneplus, "1+", 1, 0, 0, 
+            (SCM x),
+           "Return @address@hidden")
+#define FUNC_NAME s_scm_oneplus
+{
+  return scm_sum (x, SCM_I_MAKINUM (1));
+}
+#undef FUNC_NAME
+
+
 SCM_GPROC1 (s_difference, "-", scm_tc7_asubr, scm_difference, g_difference);
 /* If called with one argument @var{z1}, address@hidden returned. Otherwise
  * the sum of all but the first argument are subtracted from the first
@@ -4342,6 +4352,16 @@
 #undef FUNC_NAME
 
 
+SCM_DEFINE (scm_oneminus, "1-", 1, 0, 0, 
+            (SCM x),
+           "Return @address@hidden")
+#define FUNC_NAME s_scm_oneminus
+{
+  return scm_difference (x, SCM_I_MAKINUM (1));
+}
+#undef FUNC_NAME
+
+
 SCM_GPROC1 (s_product, "*", scm_tc7_asubr, scm_product, g_product);
 /* "Return the product of all arguments.  If called without arguments,\n"
  * "1 is returned."

reply via email to

[Prev in Thread] Current Thread [Next in Thread]