This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-11-30
Channels
- # admin-announcements (13)
- # announcements (2)
- # avi (1)
- # aws (10)
- # beginners (427)
- # boot (3)
- # cider (4)
- # clara (26)
- # cljs-dev (21)
- # cljsrn (24)
- # clojure (205)
- # clojure-dev (32)
- # clojure-india (26)
- # clojure-japan (1)
- # clojure-russia (256)
- # clojurescript (41)
- # clojurex (1)
- # cursive (38)
- # datavis (99)
- # datomic (15)
- # emacs (19)
- # events (2)
- # funcool (5)
- # immutant (45)
- # ldnclj (3)
- # om (60)
- # omnext (4)
- # onyx (383)
- # overtone (7)
- # parinfer (1)
- # re-frame (3)
- # reagent (7)
- # ring (1)
- # testing (5)
bronsa: are you saying that because Long accepts long
and String
and get-in returns a box, that the compiler should prefer String?
user=> (Long. (get-in {} [:a]))
Reflection warning, /private/var/folders/xn/64jx4gzn3f72t0n2t4r0w__40000gn/T/form-init7288158808655671254.clj:1:1 - call to java.lang.Long ctor can't be resolved.
[~]> cat test/*.java
package test;
public class Test1 {
public Test1(long x) {}
public Test1(Object x) {}
public static void test(long x) {}
public static void test(Object x) {}
}
package test;
public class Test2 {
public Test2(long x) {}
public Test2(String x) {}
public static void test(long x) {}
public static void test(String x) {}
}
[~]> clj
Clojure 1.8.0-master-SNAPSHOT
user=> (set! *warn-on-reflection* true)
true
user=> (fn [x] (test.Test1. x))
#<user$eval14$fn__15 user$eval14$fn__15@4d76f3f8>
user=> (fn [x] (test.Test1/test x))
#<user$eval18$fn__19 user$eval18$fn__19@1ed6993a>
user=> (fn [x] (test.Test2. x))
Reflection warning, NO_SOURCE_PATH:4:9 - call to test.Test2 ctor can't be resolved.
#<user$eval22$fn__23 user$eval22$fn__23@b1a58a3>
Reflection warning, NO_SOURCE_PATH:6:9 - call to static method test on test.Test2 can't be resolved (argument types: unknown).
#<user$eval28$fn__29 user$eval28$fn__29@4f2410ac>
@ghadi: I tried a bunch of times to rewrite the method matching logic to be consistent, but it's too broken. it's order-dependent and inconsistent, parts of clojure.core itself expect those inconsistencies
and w/o any documentation on how it should actually behave it's impossible to say what's intended behaviour or what's an accident/bug
there are even inconsistencies between having stuff type hinted as Object and not type hinted at all
@bronsa: @ghadi: For the Cursive type inference, I had to copy that logic from Clojure, I couldn’t get it to match otherwise.
@bronsa: What am I looking at in that snippet? Test1 does resolve because anything boxable can be assigned to Object, but in Test2 that’s not the case, right?
I’m not sure I disagree with Clojure there, it’s opting for more explicitness, basically.
sure, but then it's inconsistent w/ how it behaves when Object is involved. Object is no superclass to long
True, but since we know it’s not primitive, Object is a superclass of whatever the arg is, right?
bronsa: primitive vs Box doesn't really matter right because of casting? Long is castable to long