Clojure

Transient maps lose values

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Declined
  • Affects Version/s: Release 1.3, Release 1.4
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    OS X, java 1.6.0_29

Description

I have tested this on the latest clojure 1.4 alpha (1.4.0-alpha5).

I am not exactly sure what the problem is w/ transient maps, but at a certain point they appear to lose values (values that are inserted into the maps w/ assoc! do not get saved).

I have a test script that illustrates this bug:

https://gist.github.com/497879a727dabac46ec3

All the values up to content-length are saved, but content-length never makes it into the transient map.

Activity

Hide
Tassilo Horn added a comment -

This is no bug, but you use assoc! wrongly. Just like with assoc, you need to use the return value of the call instead of "bashing the transient map in place". I.e., in your code, replace the doto with ->, which threads the result of each assoc! call to the next one, returning the last value.

BTW: This came up on the list the last days, too. See:

https://groups.google.com/d/msg/clojure/rmLLnRx5p3U/10GYNQdTVksJ

Show
Tassilo Horn added a comment - This is no bug, but you use assoc! wrongly. Just like with assoc, you need to use the return value of the call instead of "bashing the transient map in place". I.e., in your code, replace the doto with ->, which threads the result of each assoc! call to the next one, returning the last value. BTW: This came up on the list the last days, too. See: https://groups.google.com/d/msg/clojure/rmLLnRx5p3U/10GYNQdTVksJ
Hide
Tassilo Horn added a comment -

This is no bug but a usage error.

Show
Tassilo Horn added a comment - This is no bug but a usage error.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: