This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
TO JULIAN: Re: two modules: (ice-9 rationals), (ice-9 rational-object)
- To: "K Witt" <kwitt2 at earthlink dot net>
- Subject: TO JULIAN: Re: two modules: (ice-9 rationals), (ice-9 rational-object)
- From: Mikael Djurfeldt <mdj at mdj dot nada dot kth dot se>
- Date: 01 Jul 2000 19:42:04 +0200
- Cc: <guile at sourceware dot cygnus dot com>
- Cc: djurfeldt at nada dot kth dot se
- References: <000e01bfe23c$ed173720$654ebfa8@default>
"K Witt" <kwitt2@earthlink.net> writes:
> [Note: I am not yet on this mailing list, do to email problems, so
> it'd be nice if replies to this message would be CC'd back to me,
> with TO JULIAN: on the subject line. Sorry for in inconvenience.]
>
>
> Greetings.
>
> Attached is a gzipped tarball containing two scheme files named
> rationals.scm and rational-object.scm, which are respectively defined
> as (ice-9 rationals) and (ice-9 rational-object).
Great! Thanks!
> Through goops, the rational objects defined by (ice-9 rational-object)
> can act like actual number numbers. There are some limitations, which
> are listed here:
> 1) Since goops wont make methods for some primitives like
> `expt',
This should really be implemented as a C level GPROC just as the other
numeric operations. If you supply a patch to do this, I'll apply it.
> 2) You must *initialize* rational objects, using
> make-rational. You don't have to do that for normal
> numbers.
As soon as GOOPS has been added to Guile, we will supply some generic
function which will allow customization of reading, "/", "quotient"
etc as a part of the MOP.
> Methods for all the other functions of (ice-9 rationals) exist in
> (ice-9 rational-object) but the two may not coexist (yet -- I may
> have to work on how Goops does its generic functions or see if its
> MOP will suffice).
Since the plan is to merge GOOPS into Guile, these two modules can
probably merge into one in the near future.
> Note that the functions in both modules tend to become sluggish for
> very high numerators or denominators. The only real solution I see to
> this is to implement rationals as primitive types in Guile.
There is also a plan to start using the GNU multiprecision library. I
believe this library has rational support.
> guile> (use-modules (ice-9 rational-object))
> guile> (define rat (make-rational 3/9))
> guile> rat
> <rational: 1/3>
Why don't rationals print as 1/3?