Just this week I have wished for an extended version of `assoc-in`
more than once. The reason is convenience, e.g. in the context of a
ring middleware:

(assoc-in response
   [:headers "Location"] "/homepage"
   [:session :user-id] user-id)

Extending `assoc-in` would also achieve parity with `assoc`, which
does accept multiple kv pairs.

On Wed, Aug 17, 2016 at 8:59 PM, Timothy Baldridge <tbaldri...@gmail.com> wrote:
> When I see mailing list posts like this I like to play the devil's advocate
> a bit (at least in my own mind) and try to find problems with including a
> given patch in Clojure.
>
> A few things to consider:
> 1) There are really three answers to patches: "yes", "no" and "not now".
> That is to say, because a patch hasn't been accepted doesn't mean it's bad,
> it just means that it may not be the right time for the patch or perhaps
> there are other tickets more pressing for the version of Clojure under
> development. So don't let the time since patch creation disappoint you, it
> doesn't mean all hope is lost.
>
> 2) Now I ask myself: "Why would this be in core?" Looking at this function I
> see something interesting, there's nothing about this patch that couldn't be
> added as a utility function in some separate project. So why would I want to
> force the maintainers of Clojure, now and in the future, to support some
> extra logic? The best reason I can come up with is that it saves me
> copy-and-pasting some util function around, or perhaps it keeps me from
> including another util dependency in my projects. Is that convenience worth
> the cost? I don't know, and that's not my job, thankfully :) .
>
> 3) Now I ask my self: "When have I needed this feature?" And sadly, I can't
> think of a case. That's not to say I haven't needed to call assoc-in on many
> path/value pairs, but when I do I often use a construct like this:
>
> (reduce-kv assoc-in {}
>  {[:a :b] 42
>   [:c :d] 43
>   [:d] 11})
>
> In fact, I've been thinking about this for several days, and I have yet to
> think of a situation where I'd prefer 'apply' over reduce. And I can't think
> of a situation where I've need multiple hand-written arguments to assoc-in.
>
> I also think I haven't needed this functionality because I tend to prefer
> namespaced keywords and flat maps. Or when I do have nested maps, I use
> something like prewalk to do my work. This is anecdotal evidence, but it's
> my experience.
>
> None of these things are huge, but that's my thought process when reading
> about patches.
>
> Timothy
>
> On Mon, Aug 15, 2016 at 6:53 PM, Łukasz Kożuchowski
> <lukasz.kozuchow...@gmail.com> wrote:
>>
>> Thanks for the tip. I imagine the patch author is much more sad (it's been
>> one year...).
>>
>> Łukasz Kożuchowski
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> “One of the main causes of the fall of the Roman Empire was that–lacking
> zero–they had no way to indicate successful termination of their C
> programs.”
> (Robert Firth)
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to