Good morning. Day 5 Düsseldorf to Bonn. Plan is to cross the Rhine and stay there. Go through Cologne passes the Dom and on to Bonn. I'll let you lovely people know how it goes.
And now Google maps gives a different route from last night's 😔
Wtf?
Bloody hot today. Out average speed lower.
Going to be a long day
Ok, we cheated. We took the train from Cologne to Bonn. Too hot.
And my phone got so hot during the day it shutdown all the apps.
Safe travels! And good morning 🙂
good morning
Good morning!
Morning
I saw something like this in $workplace's code base today
(defn parse-x [{:keys [foo bar baz zod]}]
{:foo foo
:bar bar
:baz baz
:zod zod})
(defn parse-xs [xs]
(->> xs
(map parse-x)
(sort-by :foo)))
I hope whoever wrote that took a nap afterwardsso ... parse-x is poor man's select-keys?
just that it also fills in nil values?
Yes, except no caller ever has other keys than those keys. And it doesn't matter downstream whether keys have nil values or are exempt from the map.
😂
🫠
So it's more like a verbose identity for this particular use case. (I tested it with clojure.data/diff to ensure that my eyes weren't lying to me)
(clojure.data/diff x (parse-x x))
I've come to dislike excessive indirection. I don't think I've seen completely unnecessary indirection in the wild 😄
Maybe the author had excessive experience plucking from structs and putting back into different structs, and followed a pattern they'd seen in a different codebase? parse-x does make the keys known.
That's a wat for me
Sure. I've also come to dislike excessive indirection; often, you can just inline clojure core functions and have completely readable code.
I'm also a fan of making keys known, so I shun e.g. frivolous use of (merge x y). What's the result? Who knows. Instead, I do
(let [{:keys [the keys I need from]} x
{:keys [and]} y]
{:the the
:and and})Silly example of course
@teodorlu I think the developer is certainly a "try to follow existing patterns"-type of person
Which is not bad, but remember to (apply brain)
It is hot though, so maybe the brain isn't worth much 🫠
I merge and assoc all the way! Heterogenuous maps all the way, baby! But namespace qualified keys preferred ☺️
> I’ve come to dislike excessive indirection. “The princess is in another castle” code
I want my princesses at hand, dammit!
Now i gotta remember that foo called bar called baz and that just happens to be select-keys. Just use select-keys please, I dont have enough L1 cache in my head for your indirections
Exactly. So many home brewed names for what is really just a line or two of clojure core functions.
there is some level of ‘apply taste’ tho. At some point someone is map filter reducing one data structure into another… maybe give that a name so that I don’t have to mentally attach one :’)
Of course 🙂 It's all a balance act.
I struggle with that sometimes. Like, some people, as you suggest, try to follow some pattern and I have a hard time writing “don’t make me navigate needless indirections” but “sometimes give a thing a name to make it more clear” as a rule.
haha yeah
just think the way that I do and we'll be fine
Another possibility is to guard against mutable java.util.Map