unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Dirk Herrmann <dirk@dirk-herrmanns-seiten.de>
Cc: guile-devel@gnu.org, Marius Vollmer <mvo@zagadka.de>
Subject: Re: ratio implementation
Date: Thu, 18 Sep 2003 23:09:46 +0200	[thread overview]
Message-ID: <3F6A1F1A.8000507@dirk-herrmanns-seiten.de> (raw)
In-Reply-To: <3F66F68B.3070100@ccrma.stanford.edu>

Bill Schottstaedt wrote:

> Looks straightforward, but I may not get around to it right away.
> Should I wait for Dirk's type-related changes?

Just for your information: I have submitted a patch which does the first 
part: Introducing scm_tc7_number and turning bignums, reals and complex 
numbers from smobs into subtypes of scm_tc7_number. The patch, however, 
is quite simplistic and does not yet optimize the way the subtypes of 
scm_tc7_number are allocated. It should nevertheless provide the 
type-system infrastructure for easy integration of the fraction type.

> > 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.
>
> Ok -- "exact?" used to return #f for 3/4 -- hence the confusion.
>
>
> >> An alternative would be to make "rational?"  rational.
> > That would violate R5RS, wouldn't it?
>
> I don't think so.  You are allowed to make rational? be the same
> as real?, but you can also distinguish them.  My druthers would
> be for rational? to return #t for a ratio, #f for a float.
> Why have it at all if it is just a synonym for "real?"? 

Just a side note: We should in guile distinguish between the internal 
representation of values, and their mathematical meaning. For example, 
fixnums and bignums are two representation of integer types. They 
should, however, also report #t when queried about being rational, real 
or complex, since they are elements of all these sets. When introducing 
exact rationals, which are represented internally as a pair of two exact 
integer values, we should not name them rationals, but, for example, 
fractions.

The reason I mention this is that I want to avoid a macro SCM_RATIONAL_P 
to be introduced: The meaning of such a macro would not be clear, since 
it might either be expected to return the equivalent of rational? or 
just return true if an object was detected with an internal 
representation of a fraction.

A nice set of macros to check for numbers of a specific internal 
representation could be (names are just given as examples):

SCM_FIXNUM_P (currently named SCM_INUMP)
SCM_BIGNUM_P (currently named SCM_BIGP)
SCM_FRACTNUM_P
SCM_FLOATNUM_P (currently named SCM_REALP, which is confusing)
SCM_FLOATCPLXNUM_P (currently named SCM_COMPLEXP)

while a nice set of macros for testing for a mathematical meaning could 
be (names are probably acceptable):

SCM_EXACT_P
SCM_NUMBER_P
SCM_INTEGER_P
SCM_RATIONAL_P
SCM_REAL_P
SCM_COMPLEX_P

In the long term, we should rethink our current set of confusing names. 
For the short term, we should at least avoid to introduce more confusing 
terms, especially when introducing the new internal representation of 
fractions.

Best regards
Dirk Herrmann



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


  parent reply	other threads:[~2003-09-18 21:09 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
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 [this message]
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=3F6A1F1A.8000507@dirk-herrmanns-seiten.de \
    --to=dirk@dirk-herrmanns-seiten.de \
    --cc=guile-devel@gnu.org \
    --cc=mvo@zagadka.de \
    /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).