This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: arith. expression crashes Kawa
Jim White wrote:
Sven.Hartrumpf@fernuni-hagen.de wrote:
With current CVS version of kawa, I get the following strange behavior:
...
...
I'ld wager that is a consequence of this change:
cvs diff -D 2003-08-19 kawa/lib/numbers.scm
34,38c35,54
< (define (quotient (x :: <integer>) (y :: <integer>)) :: <integer>
< (invoke-static <integer> 'quotient x y))
<
< (define (remainder (x :: <integer>) (y :: <integer>)) :: <integer>
< (invoke-static <integer> 'remainder x y))
---
> (define (quotient (x :: <real>) (y :: <real>)) :: <real>
> (if (and (instance? x <integer>) (instance? y <integer>))
> (invoke-static <integer> 'quotient x y)
> (invoke (/ x y) 'toInt (static-field <number> 'TRUNCATE))))
>
...
I'm not sure if this is the right thing to do but changing the types for
quotient from <real> to <number> gets it to work. Changing just the
return type to <integer> didn't work because that gets a
ClassCastException when the result comes from the non-integer code.
Index: numbers.scm
===================================================================
RCS file: /cvs/kawa/kawa/kawa/lib/numbers.scm,v
retrieving revision 1.15
diff -u -r1.15 numbers.scm
--- numbers.scm 21 Aug 2003 07:03:00 -0000 1.15
+++ numbers.scm 18 Oct 2003 19:50:39 -0000
@@ -32,7 +32,7 @@
(define (abs (x :: <number>)) :: <number>
(invoke x 'abs))
-(define (quotient (x :: <real>) (y :: <real>)) :: <real>
+(define (quotient (x :: <number>) (y :: <number>)) :: <number>
(if (and (instance? x <integer>) (instance? y <integer>))
(invoke-static <integer> 'quotient x y)
(invoke (/ x y) 'toInt (static-field <number> 'TRUNCATE))))
If this or anything similar is correct, then remainder needs the same
treatment.
Jim
--
"I love deadlines. I love the whooshing sound they make as they fly by."
-- Douglas Adams