clojuredesign-podcast

Discussions around the Functional Design in Clojure podcast - https://clojuredesign.club/
lodin 2019-09-24T03:02:41.005600Z

Regarding nil safe functions, @neumann, I believe you said that nth is not nil safe, but (nth nil 0) is nil. Maybe you thought about using function application on vectors? (x 0) isn't nil safe, because the function would be nil.

neumann 2019-09-24T14:36:38.007400Z

@lodin.johan Yeah, I wasn't super clear on that point, was I? I think my real issue with nth is that the collection isn't at the end like the typical sequence functions. It's more like the map-related functions that put the collection second.

lodin 2019-09-24T15:55:00.007600Z

Yeah, that's an annoyance most of the time. And you do get a null pointer exception if you use it in a ->> and the sequence is null. 😉

nate 2019-09-24T03:06:40.005700Z

@lodin.johan you are absolutely right that passing a nil for the collection puns correctly

nate 2019-09-24T03:07:20.005900Z

I think in this case, passing nil for the index doesn't pun well and you get a NPE

nate 2019-09-24T03:08:14.006100Z

very interesting point you made about vectors as functions

nate 2019-09-24T03:08:26.006300Z

I never thought to use them like that, but they do behave correctly

nate 2019-09-24T03:08:33.006500Z

of course, when they are not nil

lodin 2019-09-24T03:23:56.006700Z

Oh. I see. What would you expect (nth coll nil) to do?

nate 2019-09-24T03:25:34.007Z

I can't think of a reasonable default