* [patch] Generalize square to java.lang.Number
@ 2015-03-13 2:27 Jamison Hope
2015-03-19 2:40 ` Per Bothner
0 siblings, 1 reply; 2+ messages in thread
From: Jamison Hope @ 2015-03-13 2:27 UTC (permalink / raw)
To: kawa@sourceware.org list
[-- Attachment #1: Type: text/plain, Size: 965 bytes --]
The attached patch generalizes square to java.lang.Number, so that it is
no more restrictive than *.
Before:
#|kawa:1|# (define a (java.lang.Integer[] 1 2 3 4 5))
#|kawa:2|# (map square a)
Argument #1 '1' to 'square' has wrong type (java.lang.Integer) (java.lang.Integer cannot be cast to gnu.math.Quantity)
at atInteractiveLevel$2.run(stdin:2)
at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:317)
at gnu.expr.ModuleExp.evalModule(ModuleExp.java:219)
at kawa.Shell.run(Shell.java:291)
at kawa.Shell.run(Shell.java:203)
at kawa.Shell.run(Shell.java:184)
at kawa.repl.main(repl.java:903)
Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to gnu.math.Quantity
... 7 more
After:
#|kawa:1|# (define a (java.lang.Integer[] 1 2 3 4 5))
#|kawa:2|# (map square a)
(1 4 9 16 25)
#|kawa:3|# (*:getClass (cadr (map square a)))
class java.lang.Integer
--
Jamison Hope
The PTR Group
www.theptrgroup.com
[-- Attachment #2: generalize-square.patch --]
[-- Type: application/octet-stream, Size: 869 bytes --]
Index: kawa/lib/ChangeLog
===================================================================
--- kawa/lib/ChangeLog (revision 8365)
+++ kawa/lib/ChangeLog (working copy)
@@ -1,3 +1,7 @@
+2015-03-12 Jamison Hope <jrh@theptrgroup.com>
+
+ * numbers.scm (square): Generalize to java.lang.Number.
+
2015-02-26 Per Bothner <per@bothner.com>
* compile_map.scm (ListMapHelper): Rewrite result collect to
Index: kawa/lib/numbers.scm
===================================================================
--- kawa/lib/numbers.scm (revision 8365)
+++ kawa/lib/numbers.scm (working copy)
@@ -344,7 +344,7 @@
(gnu.math.Quantity:make ((num:number):sqrt)
((num:unit):sqrt))))))
-(define (square x::quantity) ::quantity
+(define (square x::java.lang.Number) ::java.lang.Number
(* x x))
(define-procedure make-rectangular
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [patch] Generalize square to java.lang.Number
2015-03-13 2:27 [patch] Generalize square to java.lang.Number Jamison Hope
@ 2015-03-19 2:40 ` Per Bothner
0 siblings, 0 replies; 2+ messages in thread
From: Per Bothner @ 2015-03-19 2:40 UTC (permalink / raw)
To: kawa
On 03/12/2015 07:27 PM, Jamison Hope wrote:
> The attached patch generalizes square to java.lang.Number, so that it is
> no more restrictive than *.
Thanks - checked in.
--
--Per Bothner
per@bothner.com http://per.bothner.com/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-19 2:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-13 2:27 [patch] Generalize square to java.lang.Number Jamison Hope
2015-03-19 2:40 ` Per Bothner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).