chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Problems with rationals


From: Peter Bex
Subject: Re: [Chicken-users] Problems with rationals
Date: Mon, 9 Apr 2012 22:45:50 +0200
User-agent: Mutt/1.4.2.3i

On Mon, Apr 09, 2012 at 09:39:06PM +0100, Mark Carter wrote:
> > If I want to reproduce this, do I need to type in anything else?
> > It doesn't happen here.
> 
> After some experimenting, the statistics eggs seems to introduce some 
> peculiarity. Here's a session:
> 
> ----------------------------------------------------------------------
> #;1> (* 1.0 5/2)
> 
> Warning: cannot represent exact fraction - coerced to flonum: "5/2"
> 2.5
> #;2> (use statistics)
> #;3> (* 1.0 5/2)
> 
> Error: (*) bad argument type: 5/2
> 
>         Call history:
> 
>         <syntax>          (* 1.0 5/2)
>         <eval>    (* 1.0 5/2)   <--
> #;3> (use numbers)
> #;4> (* 1.0 5/2)
> 2.5

This is a known problem with the numbers egg, see Thomas's post.
I didn't expect it to turn up in this particular way; a more common
way is to have a library/module that uses numbers which passes the
number to procedures in a library which doesn't, and then tries to
perform calculations on it.

The only way to truly fix this is to add numbers to core; the
way it extends the reader is a bit of a hack and it doesn't truly
replace the procedures from the Scheme module.  Even if it did, compiled
code often calls C functions directly which "bypasses" any overwriting
the numbers egg might do at the Scheme level; that's why it doesn't
even try to do this at all.

Cheers,
Peter
-- 
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music."
                                                        -- Donald Knuth



reply via email to

[Prev in Thread] Current Thread [Next in Thread]