bug-kawa
[Top][All Lists]
Advanced

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

[Bug-kawa] [bug #48938] lambda cannot be cast to java.util.Comparator


From: 坂本治
Subject: [Bug-kawa] [bug #48938] lambda cannot be cast to java.util.Comparator
Date: Mon, 29 Aug 2016 02:49:01 +0000 (UTC)
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36

URL:
  <http://savannah.gnu.org/bugs/?48938>

                 Summary: lambda cannot be cast to java.util.Comparator
                 Project: Kawa
            Submitted by: saka1029
            Submitted on: Mon 29 Aug 2016 02:48:59 AM GMT
                Category: None
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

I defined a macro.

(define-syntax ->
  (syntax-rules ()
     ((_ o)
      o)
     ((_ o (m a ...) r ...)
      (-> (invoke o 'm a ...) r ...))
     ((_ o f r ...)
      (-> (field o 'f) r ...))))

And I called java8 stream APIs.

#|kawa:68|# (-> [1 3 5 7 9 8 6 4 2]
#|(---:69|#     (stream)
#|(---:70|#     (filter (lambda (x) (<= x 5)))
#|(---:71|#     (sorted)
#|(---:72|#     (toArray))
[1 2 3 4 5]

It works fine.
But when I add an argument to 'sorted' method, it doesn't work.

#|kawa:73|# (-> [1 3 5 7 9 8 6 4 2]
#|(---:74|#     (stream)
#|(---:75|#     (filter (lambda (x) (<= x 5)))
#|(---:76|#     (sorted (lambda (a b) (- b a)))
#|(---:77|#     (toArray))
/dev/stdin:76:13: warning - type function is incompatible with required type
java.util.Comparator
java.lang.ClassCastException: gnu.expr.ModuleMethod cannot be cast to
java.util.Comparator
        at atInteractiveLevel-21.run(stdin:75)
        at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:293)
        at gnu.expr.ModuleExp.evalModule(ModuleExp.java:212)
        at kawa.Shell.run(Shell.java:291)
        at kawa.Shell.run(Shell.java:203)
        at kawa.Shell.run(Shell.java:184)
        at kawa.repl.processArgs(repl.java:687)
        at kawa.repl.main(repl.java:793)






    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?48938>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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