unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Marius Vollmer <mvo@zagadka.de>
Cc: guile-devel@gnu.org
Subject: Re: ratio implementation
Date: Mon, 15 Sep 2003 12:35:36 +0200	[thread overview]
Message-ID: <87smmyibk7.fsf@zagadka.ping.de> (raw)
In-Reply-To: <3F250809.9030108@ccrma.stanford.edu> (Bill Schottstaedt's message of "Mon, 28 Jul 2003 04:24:57 -0700")

Bill Schottstaedt <bil@ccrma.Stanford.EDU> writes:

> There is an implementation of ratios for Guile (based on CVS version
> of 27-Jul-03) at ccrma-ftp.stanford.edu:/pub/Lisp/gratio.tar.gz.
> Rather than send a huge diff, I placed the new versions of the changed
> files (all from the libguile directory) in the tarball along with
> *.diff showing the changes.

Good work, thanks!  However, I don't think we should restrict us to
longs as the numerator/denominator, we should use fixnums and bignums.
Your patch is a very good basis for this and it should be quite
straightforward to make it use SCM integers as the
numerator/denominator.

That is, instead of using "long", I'd say we simply use "SCM" and
instead of "+", "==", etc, we use use "scm_sum", "scm_num_eq_p", etc.
Also, instead of mallocing scm_t_ratio, we can use double cells, which
should be more efficient.

Any takers?

(Also I didn't really check whether your rationals behave like R5RS
demands it.  Did you?  We should be sure to follow R5RS.)

> I added numerator, denominator, rationalize and ratio?, and at the C
> level scm_make_ratio and scm_i_ratio2real (should it be
> scm_ratio2dbl?).  "ratio?" is needed because "rational?" returns #t
> if passed a real -- there has to be some way to distiguish a ratio
> from a real.

A ratio is exact, while a real is not.  Thus, I'd say that ratio? is
not really necessary.  There should be no reason to add anything eyond
R5RS for ratios.

> An alternative would be to make "rational?"  rational.

That would violate R5RS, wouldn't it?

> I don't know how the FSF/GPL copyright stuff works, but I did this
> work on my own time, did not look at any other implementation, and
> hereby donate the code to you.  I'd be happy to "sign the papers".

Thanks!  I'll get back to you about the papers when necessary.

> I decided to make minimal changes, but handling of exact/inexact
> distinctions in Guile could use some work (I am willing do this, if
> others approve).

That would be great!

> And currently (format #f "~F" 2/3) hangs, but so does (format #f
> "~B" 1.5) (in Guile 1.6.4 you get an error, but in the CVS Guile it
> hangs in mutex_lock).

This should be fixed in CVS.

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


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


  parent reply	other threads:[~2003-09-15 10:35 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-28 11:24 ratio implementation Bill Schottstaedt
2003-07-28 12:08 ` Han-Wen Nienhuys
2003-07-29  0:41 ` Kevin Ryde
2003-07-29 11:57   ` Bill Schottstaedt
2003-07-30 22:42     ` Kevin Ryde
2003-09-15 10:35 ` Marius Vollmer [this message]
2003-09-15 16:19   ` Rob Browning
2003-09-15 22:06   ` Dirk Herrmann
2003-09-15 22:59     ` Kevin Ryde
2003-09-16 11:39     ` Bill Schottstaedt
2003-09-16 21:36       ` Rob Browning
2003-09-18 21:09       ` Dirk Herrmann
2003-10-07 15:26         ` Marius Vollmer
2003-10-13 10:58           ` Bill Schottstaedt
2003-10-14  8:57             ` Marius Vollmer
2004-02-18 14:25               ` fractions.test Bill Schottstaedt
2003-10-14 12:39             ` ratio implementation Marius Vollmer
2003-10-14 22:56               ` Kevin Ryde
2003-10-14 13:03             ` Marius Vollmer
2003-10-14 23:37               ` Kevin Ryde
2003-10-16 11:49                 ` Bill Schottstaedt
2003-10-17 10:09                 ` Marius Vollmer
2003-10-17 11:47                   ` Bill Schottstaedt
2003-10-17 15:04                   ` Rob Browning
2003-10-18  0:45                   ` Kevin Ryde
2003-10-15 12:57               ` Bill Schottstaedt
2003-10-17 10:20                 ` Marius Vollmer
2003-10-17 15:14                   ` Rob Browning
2003-10-17 15:42                     ` Marius Vollmer
2003-10-14 23:01             ` Kevin Ryde
2003-10-18  0:55               ` ash using shifts (was: ratio implementation) Kevin Ryde
2003-10-07 15:24       ` ratio implementation 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=87smmyibk7.fsf@zagadka.ping.de \
    --to=mvo@zagadka.de \
    --cc=guile-devel@gnu.org \
    /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).