From: Jamison Hope <jrh@theptrgroup.com>
To: "kawa@sourceware.org list" <kawa@sourceware.org>
Subject: [patch] Generalize square to java.lang.Number
Date: Fri, 13 Mar 2015 02:27:00 -0000 [thread overview]
Message-ID: <FD72CDE7-697D-43E6-8590-3315F3F9F20A@theptrgroup.com> (raw)
[-- 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
next reply other threads:[~2015-03-13 2:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-13 2:27 Jamison Hope [this message]
2015-03-19 2:40 ` Per Bothner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=FD72CDE7-697D-43E6-8590-3315F3F9F20A@theptrgroup.com \
--to=jrh@theptrgroup.com \
--cc=kawa@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).