unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* 1+ and 1- in C
@ 2005-04-10 22:17 Kevin Ryde
  2005-04-10 22:29 ` Bruce Korb
  2005-05-24 17:03 ` Marius Vollmer
  0 siblings, 2 replies; 4+ messages in thread
From: Kevin Ryde @ 2005-04-10 22:17 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 193 bytes --]

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.


[-- Attachment #2: numbers.c.oneplus.diff --]
[-- Type: text/plain, Size: 982 bytes --]

--- 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 @math{@var{x}+1}.")
+#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}, -@var{z1} 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 @math{@var{x}-1}.")
+#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."

[-- Attachment #3: Type: text/plain, Size: 143 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-05-24 17:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-10 22:17 1+ and 1- in C Kevin Ryde
2005-04-10 22:29 ` Bruce Korb
2005-04-10 23:30   ` Kevin Ryde
2005-05-24 17:03 ` Marius Vollmer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).