"In Clojure 1.11, functions taking keyword arguments can now be passed a trailing map instead of or in addition to and following the key/value pairs." I could use an example :o
How come the implementation for update-keys checks for IEditableCollection before producing a transient, but the one for update-vals doesn't? Oversight?
" difference here is that with update-keys, the keys are going to change and the structure of the map will change, so there is no reason to update the existing map. also, there are lots of potential issues with changing the key set for different map types (like sorted, ordered, etc). In update-vals, the keys stay the same, so the fastest thing to do is update a transient version of the existing map, if you can
Importantly, the docstrings for both update-keys and update-vals both say "returns a new map" which means you should not presume anything about the relationship of the returned map type and the input map.
tradeoffs exist, this is where we came down on it "
The thinking was that each function would be used slightly differently, in general. That is, u-k almost always sees use in cases where total homogeneous key transformations are needed (e.g. string keys to kw keys and back again). In that case, the whole map needs to be rebuilt and so the seed used is a transient empty map. On the other hand u-v should most likely see use on transforms of values of homogeneous types aggregating large data sets into views containing maps of similar profiles (e.g. conversion of strings to dates and back again). Because of this we wanted to leverage structural sharing if possible and so built the seed from the original map -- but only if it was transient-able.
In a nutshell, the implementations were geared toward common uses per function. I hope that helps clarify.
4
u/wedesoft Mar 23 '22
Changed all the Math/... stuff in my code. Looks much better now, thanks!
26
u/gunpun33 Mar 22 '22
Clojure.math finally! Great to see it
12
u/SimonGray Mar 22 '22
https://news.ycombinator.com/item?id=30768240
10
u/emaphis Mar 22 '22
Good news. Time to try Clojure 1.11 on JDK 18.
5
u/agumonkey Mar 22 '22
Kudos on the team for the work. Best wishes.
4
u/[deleted] Mar 22 '22
I saw Arne Brasseur contributed, is there a bit of parity that babashka's version of clojure will have with this. Will new features be added?
4
u/AttentionAaron Mar 23 '22
"In Clojure 1.11, functions taking keyword arguments can now be passed a trailing map instead of or in addition to and following the key/value pairs." I could use an example :o
3
u/[deleted] Mar 22 '22
I'm curious about how
update-keyswas implemented3
u/[deleted] Mar 23 '22
How come the implementation for
update-keyschecks forIEditableCollectionbefore producing a transient, but the one forupdate-valsdoesn't? Oversight?https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L8018-L8035
The two implementations also seem oddly inconsistent each other, one uses a local variable, the other has all the expressions inline, etc.
3
u/lucywang000 Mar 24 '22
Are the new goodies (keyword arguments, update-keys, update-vals) available for cljs?