Fork me on GitHub
#clojuredesign-podcast
<
2019-09-24
>
lodin03:09:41

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.

nate03:09:40

@U8J6W2SC8 you are absolutely right that passing a nil for the collection puns correctly

nate03:09:20

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

nate03:09:14

very interesting point you made about vectors as functions

nate03:09:26

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

nate03:09:33

of course, when they are not nil

lodin03:09:56

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

nate03:09:34

I can't think of a reasonable default

neumann14:09:38

@U8J6W2SC8 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.

lodin15:09:00

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