Clojure

Support get from arbitrary java.util.List data types

Details

  • Type: Feature Feature
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: Release 1.7
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Approval:
    Triaged

Description

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 [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).

  1. clj-1624.diff
    23/Dec/14 12:31 AM
    2 kB
    Mike Anderson
  2. clj-1624-v2.patch
    06/Oct/17 4:22 PM
    2 kB
    Michael Blume

Activity

Hide
Mike Anderson added a comment -

Patch for CLJ-1624

Show
Mike Anderson added a comment - Patch for CLJ-1624

People

Vote (1)
Watch (0)

Dates

  • Created:
    Updated: