Re: [Chicken-users] Problems with rationals
To be fair: On Apr 9 2012, John Cowan wrote: But, blast it, if little Chibi can include a full numeric tower, why should Chicken position itself with RScheme and VX, plus a bunch of broken Schemes that always return a fixnum when multiplying fixnums, even if it's the wrong one? See http://trac.sacrideo.us/wg/wiki/NumericTower for a table of which Schemes support which numeric tower features. This table needs to be fixed wrt RScheme: jfw@ajax:~$ fshell RScheme (v0.7.3.4-b7u, 2007-05-30) Copyright (C) 1995-2005 Donovan Kolbly d.kol...@rscheme.org RScheme comes with ABSOLUTELY NO WARRANTY. type ,warranty for details; type ,help for some help top[0]=(define phi 3.1415926) value := phi top[1]=(define eee 0-i) value := eee top[2]=(/ phi eee) value := 0.+3.14159i top[3]=(/ phi (* eee eee)) value := -3.14159 top[4]=(* (/ 3 5) 5) value := 3 top[5]=(/ 3 5) value := 3/5 If you see what I mean: while rscheme seems to have bugs wrt. some type coercion, it's obviously not bound to intergers. /Jörg ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Problems with rationals
Jörg F. Wittenberger scripsit: jfw@ajax:~$ fshell RScheme (v0.7.3.4-b7u, 2007-05-30) Copyright (C) 1995-2005 Donovan Kolbly d.kol...@rscheme.org RScheme comes with ABSOLUTELY NO WARRANTY. type ,warranty for details; type ,help for some help top[0]=(define phi 3.1415926) value := phi top[1]=(define eee 0-i) value := eee top[2]=(/ phi eee) value := 0.+3.14159i top[3]=(/ phi (* eee eee)) value := -3.14159 top[4]=(* (/ 3 5) 5) value := 3 top[5]=(/ 3 5) value := 3/5 Huh. I have the same version you do, but enable_read_numeric_tower is off, and there appears to be no way to turn it on such as a configure-time switch. I tried setting it in the shell and now I have a corrupt installation. Arrgh. So by default the full numeric tower is off, and complex constants output runtime error: complex.scm:make-rectanglar:69: function stubbed out, and (/ 3 5) returns 0.6. -- No saves, Antonio, loke es morirse en su lingua. Es komoJohn Cowan kedarse soliko en el silensyo kada dya ke Dyo da, komo co...@ccil.org ser sikileoso sin saver porke. http://www.ccil.org/~cowan --Marcel Cohen, 1985 ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] Problems with rationals
Is this a bug in chicken? (rational? 6/10) = #f Also (* 1.0 5/2) produces Error: (*) bad argument type: 5/2 Call history: syntax (* 1.0 5/2) eval(* 1.0 5/2) CHICKEN (c)2008-2011 The Chicken Team (c)2000-2007 Felix L. Winkelmann Version 4.7.0.5-st linux-unix-gnu-x86 [ manyargs dload ptables ] compiled 2012-03-07 on miro (Linux) ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Problems with rationals
On Mon, Apr 09, 2012 at 09:00:10PM +0100, Mark Carter wrote: Is this a bug in chicken? (rational? 6/10) = #f Chicken by itself doesn't support ratnums. You'll need the numbers egg to get the full numeric tower (including arbitrarily large numbers and complex numbers). Also (* 1.0 5/2) produces Error: (*) bad argument type: 5/2 If I want to reproduce this, do I need to type in anything else? It doesn't happen here. 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 ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Problems with rationals
On Mon, 2012-04-09 at 21:00 +0100, Mark Carter wrote: Is this a bug in chicken? (rational? 6/10) = #f Also (* 1.0 5/2) produces Error: (*) bad argument type: 5/2 [...] Hello, this looks strange. While CHICKEN does not support exact fractions out of the box, reading a number in fractional notation should simply issue a warning and return a floating point number. Also, when I apply the rational? predicate from CHICKEN's core library to a floating point number I get the answer #t: $ csi -n CHICKEN (c)2008-2011 The Chicken Team (c)2000-2007 Felix L. Winkelmann Version 4.7.4 (rev ad149e7) linux-unix-gnu-x86-64 [ 64bit manyargs dload ptables ] compiled 2012-02-07 on hd-t1179cl (Linux) #;1 (rational? 5/2) Warning: cannot represent exact fraction - coerced to flonum: 5/2 #t #;2 (* 1.0 5/2) Warning: cannot represent exact fraction - coerced to flonum: 5/2 2.5 One way I can reproduce your problems is by loading but not importing the numbers extension library, which adds support for arbitrary precision arithmetic and exact fractions to CHICKEN: $ csi -n [...] #;1 (require-library numbers) ; loading /usr/lib/chicken/6/numbers.so ... #;2 (rational? 5/2) #f #;3 (* 1.0 5/2) Error: (*) bad argument type: 5/2 Call history: syntax (* 1.0 5/2) eval(* 1.0 5/2) -- This, however, is a misuse of the numbers library. The problem here is that by loading the library the standard reader of CHICKEN is modified. The fractional number notation then produces objects not understood by CHICKEN's core libraries and to work with them you also have to import the versions of arithmetic operators and numerical predicates that are provided by the numbers library. Ciao, Thomas -- When C++ is your hammer, every problem looks like your thumb. ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Problems with rationals
Thomas Chust scripsit: One way I can reproduce your problems is by loading but not importing the numbers extension library, which adds support for arbitrary precision arithmetic and exact fractions to CHICKEN: Nice catch. A warning should be put in the numbers egg documentation not to do that. -- John Cowan co...@ccil.org http://ccil.org/~cowan The penguin geeks is happy / As under the waves they lark The closed-source geeks ain't happy / They sad cause they in the dark But geeks in the dark is lucky / They in for a worser treat One day when the Borg go belly-up / Guess who wind up on the street. ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Problems with rationals
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 ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Problems with rationals
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 ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Problems with rationals
Peter Bex scripsit: 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. I proposed an alternative to Felix several years ago, namely to do things in the core via hooks which can be set at run-time when you load the numbers egg. That way everything behaves systematically except compiled code that inlines procedures based on type information. Felix said this was too big and comprehensive a change. But, blast it, if little Chibi can include a full numeric tower, why should Chicken position itself with RScheme and VX, plus a bunch of broken Schemes that always return a fixnum when multiplying fixnums, even if it's the wrong one? See http://trac.sacrideo.us/wg/wiki/NumericTower for a table of which Schemes support which numeric tower features. -- First known example of political correctness: John Cowan After Nurhachi had united all the other http://www.ccil.org/~cowan Jurchen tribes under the leadership of the co...@ccil.org Manchus, his successor Abahai (1592-1643) issued an order that the name Jurchen should --S. Robert Ramsey, be banned, and from then on, they were all The Languages of China to be called Manchus. ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users