title: Is there an idiomatic alternative to nil-punning in Clojure?
body: <p>I'm reading some Clojure code at the moment that has a bunch of uninitialised values as <code>nil</code> for a numeric value in a record that gets passed around. </p>
  
  <p>Now lots of the Clojure libraries <a href="https://stackoverflow.com/questions/6045404/why-clojure-idiom-prefer-to-return-nil-instead-of-empty-list-like-scheme">treat this as idiomatic</a>. Which means that it is an accepted convention. </p>
  
  <p>But it also leads to <code>NullPointerException</code>, because not all the Clojure core functions can handle a <code>nil</code> as input. (Nor should they). </p>
  
  <p>Other languages have the concept of <code>Maybe</code> or <code>Option</code> to proxy the value in the event that it is null, as a way of mitigating the <code>NullPointerException</code> risk. This is possible in Clojure - <a href="https://stackoverflow.com/questions/5839697/why-is-the-use-of-maybe-option-not-so-pervasive-in-clojure">but not very common</a>. </p>
  
  <p>You can do some tricks with <code>fnil</code> but it doesn't solve every problem. </p>
  
  <p>Another alternative is simply to set the uninitialised value to a symbol like <code>:empty-value</code> to force the user to handle this scenario explicitly in all the handling code. But this isn't really a big step-up from <code>nil</code> - because you don't really discover all the scenarios (in other people's code) until run-time. </p>
  
  <p>My question is: <strong>Is there an idiomatic alternative to nil-punning in Clojure?</strong></p>