morning! 🙌
morning
good morning
I was teaching bachelor students yesterday. It went quite well even though I started at 14:40 and their first class was at 8:00.
good morning
Good morning!
When I need a keyword as a string, without the :, but preserving the namespace, I always did (subs (str kw) 1), which seems to be the established pattern to do this. BUT turns out you can also do (str (symbol kw)), which looks nicer IMO and is also a little faster.
I also much prefer the semantics of (str (symbol kw)) over (subs (str kw) 1) The former kinda speaks in the language of Clojure, the latter reads like a hack.
that's what I meant with "looks nicer" 🙂
Not a little, relatively speaking
oh yeah? quick microbenchmarking gave me maybe 10~20% improvement
20% is not a little It's not orders of magnitude but not negligible imo
I guess it depends on a lot on what you're doing for this to show up in overall numbers
"It depends" Dammit 😁
This works since clojure 1.10 which explains the historical way of doing it
yeah I thought it might be something like that but don't have an encyclopedic memory of API changes 🙂
I just have a command line in which I can try this out ;)
Anybody here getting any mileage out of Cognitect's anomalies?
Finally got around to reading up on hierarchies and defmulti -- that's very nice @mpenet Thank you!
Very cool. I think I’ll just use them for basic categorisation and nothing else.
I am considering improving my user-facing error pages based on this article https://mbezjak.github.io/posts/exception-translation/ and I was pondering whether to combine this with anomalies, using those as a categorisation system
I think we use them at work but not extensively. I like the idea. There's a library that is inspired by anomalies the extends the idea into actual exceptions. Not at my desk but I think it's from @mpenet company?
we actually use it a lot. We have hierarchies of keywords that we use in ex-infos that then later dict behavior/handling in various contexts: like logging, alerting, http statuses and whatnot
like foo.compute.vm/not-found child of exoscale.ex/not-found, we then have multimethod for each context that does the right thing from the same hierarchy (:hierarchy opt in defmulti)
Interesting. I've never used hierarchies...
(defmulti ex->alert ... :hierarchy ex/hierarchy) (defmulti ex->logging ...) (defmulti ex->http-status ...) etc
I love them, it's a hidden gem
Good bouquet morning
morning!