* 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
* Re: 1+ and 1- in C
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
1 sibling, 1 reply; 4+ messages in thread
From: Bruce Korb @ 2005-04-10 22:29 UTC (permalink / raw)
On Sunday 10 April 2005 03:17 pm, Kevin Ryde wrote:
> 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.
Shouldn't the name for the subtraction code be ``less one'' or
the alias be ``-1+'' or some such? You are decrementing, yes?
_______________________________________________
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
* Re: 1+ and 1- in C
2005-04-10 22:29 ` Bruce Korb
@ 2005-04-10 23:30 ` Kevin Ryde
0 siblings, 0 replies; 4+ messages in thread
From: Kevin Ryde @ 2005-04-10 23:30 UTC (permalink / raw)
Cc: guile-devel
Bruce Korb <bruce.korb@gmail.com> writes:
>
> Shouldn't the name for the subtraction code be ``less one''
The C name? That can be anything.
> or the alias be ``-1+''
I guess that was r2rs, or something. It's gone in 1.8.
I'm only looking at moving a bit of what's already in boot-9.
Personally I quite like 1-.
> You are decrementing, yes?
Yep.
_______________________________________________
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
* Re: 1+ and 1- in C
2005-04-10 22:17 1+ and 1- in C Kevin Ryde
2005-04-10 22:29 ` Bruce Korb
@ 2005-05-24 17:03 ` Marius Vollmer
1 sibling, 0 replies; 4+ messages in thread
From: Marius Vollmer @ 2005-05-24 17:03 UTC (permalink / raw)
Kevin Ryde <user42@zip.com.au> writes:
> I propose to do 1+ and 1- in C so they're as fast as plain + and -.
Yes, why not. Maybe it would even be worth it to special case
fixnums.
--
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405
_______________________________________________
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).