Clojure

Transient maps can't be assoc!'d to contain more than 8 elements.

Details

  • Type: Task Task
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Declined
  • Affects Version/s: Release 1.6
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Environment:
    Linux, Fedora 20
    Clojure 1.6.0
    OpenJDK 64-Bit Server VM 1.7.0_79-mockbuild_2015_04_15_06_33-b00

Description

(let [x (transient {})] (dotimes [i 30] (assoc! x i 0)) (persistent! x))
Will result in

{0 0, 1 0, 2 0, 3 0, 4 0, 5 0, 6 0, 7 0}

instead of the expected 30 element map.

I'm not sure if this is fixed in the most recent version (development) but it doesn't work in 1.6.0.

Activity

Hide
Alex Miller added a comment -

This is not correct usage of transient maps. You must use the return value of assoc! for further updates, not bash the same instance. In other words, the update model is the same as with normal maps. There is an outstanding ticket to tweak the docstring slightly to make this clearer.

See a similar example with transient vectors at http://clojure.org/transients.

Show
Alex Miller added a comment - This is not correct usage of transient maps. You must use the return value of assoc! for further updates, not bash the same instance. In other words, the update model is the same as with normal maps. There is an outstanding ticket to tweak the docstring slightly to make this clearer. See a similar example with transient vectors at http://clojure.org/transients.
Hide
Peter Herniman added a comment -

Ah ok, looking at the example on clojure.org clears things up a lot.
I'm not too sure if the docstring does need updating, the tutorial on transients does state that you need to capture the return value explicitly.
Thanks!

Show
Peter Herniman added a comment - Ah ok, looking at the example on clojure.org clears things up a lot. I'm not too sure if the docstring does need updating, the tutorial on transients does state that you need to capture the return value explicitly. Thanks!

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: