Clojure

Missing dissoc-in

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: Release 1.4
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test
  • Approval:
    Triaged

Description

There is no clojure.core/dissoc-in although there is an assoc-in.
It is correct that dissoc-in can be build with update-in and dissoc but this is an argument against assoc-in as well.
When a shortcut for assoc-in is provided, there should also be one for dissoc-in for consistency reasons.
Implementation is analogical to assoc-in.

Activity

Hide
Andy Fingerhut added a comment -

Patch clj-1063-add-dissoc-in-patch-v2.txt dated Sep 13 2012 supersedes 001-dissoc-in.diff dated Sep 7 2012. It fixes a typo (missing final " in doc string), and adds a test case for the new function.

Show
Andy Fingerhut added a comment - Patch clj-1063-add-dissoc-in-patch-v2.txt dated Sep 13 2012 supersedes 001-dissoc-in.diff dated Sep 7 2012. It fixes a typo (missing final " in doc string), and adds a test case for the new function.
Hide
Nicola Mometto added a comment -

Thanks for the fix Andy

Show
Nicola Mometto added a comment - Thanks for the fix Andy
Hide
Andy Fingerhut added a comment -

This proposed dissoc-in should be compared with the one in clojure.core.incubator which I just happened across. I see they look different, but haven't examined to see if there are any behavior differences.

https://github.com/clojure/core.incubator/blob/master/src/main/clojure/clojure/core/incubator.clj

Show
Andy Fingerhut added a comment - This proposed dissoc-in should be compared with the one in clojure.core.incubator which I just happened across. I see they look different, but haven't examined to see if there are any behavior differences. https://github.com/clojure/core.incubator/blob/master/src/main/clojure/clojure/core/incubator.clj
Hide
Nicola Mometto added a comment - - edited

dissoc-in in clojure.core.incubator recursively removes empty maps

user=> (clojure.core.incubator/dissoc-in {:a {:b {:c 1}}} [:a :b :c])
{}

while the one in this patch doesn't (as I would expect)

user=> (dissoc-in {:a {:b {:c 1}}} [:a :b :c])
{:a {:b {}}}

Show
Nicola Mometto added a comment - - edited dissoc-in in clojure.core.incubator recursively removes empty maps user=> (clojure.core.incubator/dissoc-in {:a {:b {:c 1}}} [:a :b :c]) {} while the one in this patch doesn't (as I would expect) user=> (dissoc-in {:a {:b {:c 1}}} [:a :b :c]) {:a {:b {}}}
Hide
Stuart Halloway added a comment -

Please do this work in the incubator.

Show
Stuart Halloway added a comment - Please do this work in the incubator.
Hide
Andrew Rosa added a comment -

Keeping the empty paths is really the most expected thing to do? I say, since both assoc-in/update-in create paths along the way this behavior looks to be the real "dual".

What kind of bad things could happen that nil punning does not deal well with it? Those issues would be too much obscure for dissoc-in user's point of view?

Show
Andrew Rosa added a comment - Keeping the empty paths is really the most expected thing to do? I say, since both assoc-in/update-in create paths along the way this behavior looks to be the real "dual". What kind of bad things could happen that nil punning does not deal well with it? Those issues would be too much obscure for dissoc-in user's point of view?

People

Vote (6)
Watch (5)

Dates

  • Created:
    Updated: