clojure-uk

A place for people in the UK, near the UK, visiting the UK, planning to visit the UK or just vaguely interested to randomly chat about things (often vi and emacs, occasionally clojure). More general the #ldnclj
djm 2021-04-19T05:48:03.211200Z

👋

dharrigan 2021-04-19T06:22:58.211400Z

Good Morning!

alexlynham 2021-04-19T07:21:45.211500Z

morning

thomas 2021-04-19T07:25:37.211700Z

morning

2021-04-19T08:03:39.211900Z

Morn'

mccraigmccraig 2021-04-19T08:18:27.212500Z

mån¡

2021-04-19T08:20:47.213100Z

Mórning

dharrigan 2021-04-19T08:20:54.213300Z

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

dharrigan 2021-04-19T08:21:21.213500Z

i.e.,

dharrigan 2021-04-19T08:21:25.213700Z

(def config {:foo {:bar nil}})

(when-some [{{:keys [bar]} :foo} config]
  (format "This is %s" bar)) ;; "This is null"

dharrigan 2021-04-19T08:22:06.214100Z

The doc's say that when-some will only evaluate the body if the test is not nil.

mccraigmccraig 2021-04-19T08:27:08.215100Z

the test is the whole bound value @dharrigan, not something destructured out of it - and config is not nil

dharrigan 2021-04-19T08:27:36.215500Z

that makes sense, yup. still, had to learn that 🙂

dharrigan 2021-04-19T08:28:06.216200Z

so is there a better way of writing this so that if "bar" is nil, then not to execute the body?

dharrigan 2021-04-19T08:28:28.216700Z

I was thinking of just testing again i.e., a nested (when bar ,,,,,)

2021-04-19T08:33:57.217100Z

Have people seen this by any chance? https://github.com/IGJoshua/farolero

dharrigan 2021-04-19T08:34:15.217500Z

I was reading about it this weekend, prompted by the blog posting

2021-04-19T08:35:11.218500Z

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 😃...

2021-04-19T08:35:46.219200Z

Can you link the blog post? I don't think I've seen it...

dharrigan 2021-04-19T08:37:45.220400Z

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

dharrigan 2021-04-19T08:38:30.221Z

I'm not sure tbh, I will definitely need to spend some more time experimenting and learning to see if it works for me 😉

mccraigmccraig 2021-04-19T08:38:31.221100Z

that's what i would do

dharrigan 2021-04-19T08:38:41.221300Z

:thumbsup: that's what I did 🙂

dharrigan 2021-04-19T08:39:05.221600Z

Here's the blog post btw:

dharrigan 2021-04-19T08:39:10.221800Z

<https://andreyorst.gitlab.io/posts/2021-04-17-condition-system-in-clojure/>

2021-04-19T08:49:06.222600Z

Thanks 😃... I mean I'm hoping it will allow for more flexibility in dealing with exceptions...

dharrigan 2021-04-19T08:53:00.223200Z

Yes, agreed. I am eager to delve further into it and see if can help my applications 🙂

dharrigan 2021-04-19T20:15:21.224200Z

If I recall, someone here got the "Software Design for Flexibility" book by Chris Hanson and Gerald Jay Sussman

2021-04-20T07:41:55.225200Z

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.

dharrigan 2021-04-20T08:10:05.225600Z

Thanks for the mini-review!

dharrigan 2021-04-19T20:15:35.224600Z

Interested to hear a quick opinion on it 🙂