unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Kevin Ryde <user42@zip.com.au>
Subject: 1+ and 1- in C
Date: Mon, 11 Apr 2005 08:17:00 +1000	[thread overview]
Message-ID: <87is2uuvj7.fsf@zip.com.au> (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

             reply	other threads:[~2005-04-10 22:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-10 22:17 Kevin Ryde [this message]
2005-04-10 22:29 ` 1+ and 1- in C Bruce Korb
2005-04-10 23:30   ` Kevin Ryde
2005-05-24 17:03 ` Marius Vollmer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87is2uuvj7.fsf@zip.com.au \
    --to=user42@zip.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).