👋
Good Morning!
morning
morning
Morn'
mån¡
Mórning
I was a bit surprised to learn that destructuring a map, that has a nil, using either when-some
or when-let
doesn't do what I thought it might do
i.e.,
(def config {:foo {:bar nil}})
(when-some [{{:keys [bar]} :foo} config]
(format "This is %s" bar)) ;; "This is null"
The doc's say that when-some
will only evaluate the body if the test is not nil.
the test is the whole bound value @dharrigan, not something destructured out of it - and config
is not nil
that makes sense, yup. still, had to learn that 🙂
so is there a better way of writing this so that if "bar" is nil, then not to execute the body?
I was thinking of just testing again i.e., a nested (when bar ,,,,,)
Have people seen this by any chance? https://github.com/IGJoshua/farolero
I was reading about it this weekend, prompted by the blog posting
I've not used CL style exceptions much, but they seem handy, I'm assuming they handle normal js / java exceptions as well, would be cool to see some more interesting things happening here 😃...
Can you link the blog post? I don't think I've seen it...
My current understanding, and I believe something the blog author also comments upon, is that because (at least on the JVM) Clojure, being a hosted language, the normal paradigms of try, catch
and if-some
(and the ilk) are very common, then it may feel a bit unnatural
I'm not sure tbh, I will definitely need to spend some more time experimenting and learning to see if it works for me 😉
that's what i would do
:thumbsup: that's what I did 🙂
Here's the blog post btw:
<https://andreyorst.gitlab.io/posts/2021-04-17-condition-system-in-clojure/>
Thanks 😃... I mean I'm hoping it will allow for more flexibility in dealing with exceptions...
Yes, agreed. I am eager to delve further into it and see if can help my applications 🙂
If I recall, someone here got the "Software Design for Flexibility" book by Chris Hanson and Gerald Jay Sussman
It’s good. I’ve only read the first two or three chapters so far. I’m not sure for many people the name reflects the contents. It’s more of a fugue on compositional systems. Obviously composition is a way to build flexible software, but in places it is a bit detached from practical applications typical developers face. That’s not to say that it’s not practical, just that things like the combinator system in chapter 1 aren’t really presented as a solution to a real world problem. It’s not really contrasted to the alternative, and iirc there’s no final program built from the combinators they make which was a little disappointing. Being a long time fan of Sussman though the contents are exactly what I was expecting, and why I bought it, so no real complaints from me.
Thanks for the mini-review!
Interested to hear a quick opinion on it 🙂