This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-12-11
Channels
- # adventofcode (108)
- # announcements (4)
- # aws (11)
- # babashka (39)
- # beginners (199)
- # calva (12)
- # clj-kondo (17)
- # cljs-dev (1)
- # clojure (115)
- # clojure-dev (9)
- # clojure-europe (98)
- # clojure-italy (17)
- # clojure-nl (4)
- # clojure-norway (3)
- # clojure-seattle (7)
- # clojure-sweden (6)
- # clojure-switzerland (5)
- # clojure-uk (15)
- # clojurescript (41)
- # code-reviews (36)
- # conjure (7)
- # datomic (1)
- # emacs (1)
- # events (1)
- # fulcro (26)
- # graalvm (2)
- # helix (35)
- # jackdaw (2)
- # jobs (9)
- # jobs-discuss (5)
- # lambdaisland (2)
- # meander (24)
- # off-topic (80)
- # pathom (22)
- # pedestal (1)
- # portal (20)
- # re-frame (3)
- # releases (1)
- # reveal (13)
- # rewrite-clj (1)
- # shadow-cljs (8)
- # specter (5)
- # sql (4)
I guess it's expected that the non-inlined version of alength
uses reflection, right?
well you don't care if it's inlined :)
maybe the inlined one does as well btw. it's the same.
user=> (. clojure.lang.RT (alength (into-array [1 2 3])))
Reflection warning, NO_SOURCE_PATH:1:1 - call to static method alength on clojure.lang.RT can't be resolved (argument types: unknown).
3
just wanted to check if this is expectedI don’t think so w how inlining works
Given the amount of time I’ve spent optimizing array code in bytecode with Clojure, I’m pretty sure I would have noticed that
$ bb -e "(count (into-array [1 2 3]))"
3
$ bb -e "(alength (into-array [1 2 3]))"
----- Error --------------------------------------------------------------------
Type: java.lang.ClassNotFoundException
Message: clojure.lang.RT
^ the last error is because of the reflection at runtime, I think, because it's not statically clear which alength method it's going to callSort of amusing, because the jvm alength instruction doesn't care about the array type, so doesn't require reflection, but you can't write a java method that takes any array type (prims or objects), so RT has a bunch of static methods, alength could call any which introduces reflection