This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

TO JULIAN: Re: two modules: (ice-9 rationals), (ice-9 rational-object)


"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?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]