Clojure

Make conj assoc dissoc and transient versions handle args similarly

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: Release 1.4, Release 1.5
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test

Description

A discussion came up in the Clojure Google group about conj giving an error when taking only a coll as an argument, as opposed to disj which works for this case:

https://groups.google.com/forum/?fromgroups=#!topic/clojure/Z9mFxsTYTqQ

I looked through the rest of the code for similar cases, and found that conj! assoc assoc! and disj! also had the same property, and there were some other differences between them in how different numbers of arguments were handled, such as:

conj handles an arbitrary number of arguments, but conj! does not.
assoc checks for a final key with no value specified (CLJ-1052), but assoc! did not.

Activity

Andy Fingerhut made changes -
Field Original Value New Value
Summary Make conj assoc dissoc and transient versions handle 1-arg case Make conj assoc dissoc and transient versions handle args similarly
Hide
Andy Fingerhut added a comment -

clj-1103-make-conj-assoc-dissoc-handle-args-similarly-v1.txt dated Nov 4 2012 makes conj conj! assoc assoc! dissoc dissoc! handle args similarly to each other.

Show
Andy Fingerhut added a comment - clj-1103-make-conj-assoc-dissoc-handle-args-similarly-v1.txt dated Nov 4 2012 makes conj conj! assoc assoc! dissoc dissoc! handle args similarly to each other.
Andy Fingerhut made changes -
Attachment clj-1103-make-conj-assoc-dissoc-handle-args-similarly-v1.txt [ 11663 ]
Andy Fingerhut made changes -
Patch Code and Test [ 10002 ]
Hide
Brandon Bloom added a comment -

I too ran into this and started an additional discussion here: https://groups.google.com/d/topic/clojure-dev/wL5hllfhw4M/discussion

In particular, I don't buy the argument that (into coll xs) is sufficient, since into implies conj and there isn't an terse and idiomatic way to write (into map (parition 2 keyvals))

So +1 from me

Show
Brandon Bloom added a comment - I too ran into this and started an additional discussion here: https://groups.google.com/d/topic/clojure-dev/wL5hllfhw4M/discussion In particular, I don't buy the argument that (into coll xs) is sufficient, since into implies conj and there isn't an terse and idiomatic way to write (into map (parition 2 keyvals)) So +1 from me
Hide
Andy Fingerhut added a comment -

Patch clj-1103-2.diff is identical to the previous patch clj-1103-make-conj-assoc-dissoc-handle-args-similarly-v1.txt except it applies cleanly to latest master. The only changes were some changed context lines in a test file.

Show
Andy Fingerhut added a comment - Patch clj-1103-2.diff is identical to the previous patch clj-1103-make-conj-assoc-dissoc-handle-args-similarly-v1.txt except it applies cleanly to latest master. The only changes were some changed context lines in a test file.
Andy Fingerhut made changes -
Attachment clj-1103-2.diff [ 12459 ]
Hide
Andy Fingerhut added a comment -

Patch clj-1103-3.diff is identical to the patch clj-1103-2.diff, except it applies cleanly to latest master. The only changes were some doc strings for assoc! and dissoc! in the context lines of the patch.

Show
Andy Fingerhut added a comment - Patch clj-1103-3.diff is identical to the patch clj-1103-2.diff, except it applies cleanly to latest master. The only changes were some doc strings for assoc! and dissoc! in the context lines of the patch.
Andy Fingerhut made changes -
Attachment clj-1103-3.diff [ 12481 ]
Andy Fingerhut made changes -
Attachment clj-1103-2.diff [ 12459 ]
Andy Fingerhut made changes -
Attachment clj-1103-make-conj-assoc-dissoc-handle-args-similarly-v1.txt [ 11663 ]
Hide
Andy Fingerhut added a comment -

Patch clj-1103-4.diff is identical to the previous clj-1103-3.diff, except it updates some context lines so that it applies cleanly to latest Clojure master as of today.

Show
Andy Fingerhut added a comment - Patch clj-1103-4.diff is identical to the previous clj-1103-3.diff, except it updates some context lines so that it applies cleanly to latest Clojure master as of today.
Andy Fingerhut made changes -
Attachment clj-1103-4.diff [ 12791 ]
Andy Fingerhut made changes -
Attachment clj-1103-3.diff [ 12481 ]

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated: