Welcome! Please see the About page for a little more info on how this works.

0 votes
in Java Interop by

Currently "get", "get-in" and related functions in clojure.core work on Clojure vectors, maps and Java arrays, but do not work on instances of java.util.List

(def al (java.util.Arrays/asList (object-array (link: 1 2 3 4))))
(get al 2)
=> nil

This makes it inconvenient to work with nested structures of Java objects that could otherwise be viewed as similar to nested Clojure data structures.

This is also inconsistent with other clojure.core functions that do support arbitrary java.util.List instances (e.g. "nth" and "count")

With a small change to RT.java, it is possible to allow core functions to operate on arbitrary instances of java.util.List. There does not appear to be any significant downside to this change (it is not on the fast path so will not affect regular ILookup or Map checks).

2 Answers

0 votes
by

Comment made by: mikera

Patch for CLJ-1624

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-1624 (reported by mikera)
...