title: Common Lisp idioms for argument checking and other paranoia?
body: <p>This question is about coding conventions, best practices, and style in production, mission-critical Common-Lisp code.  I perused Google's Common-Lisp Style Guide (<a href="http://tinyurl.com/qfvnqcx">http://tinyurl.com/qfvnqcx</a>), but didn't find anything clearly addressing my specific concern, which I express by example and by contrast to C/C++, Java, etc.  I also did a quick look around Common-Lisp code bases on Github, and I did not see lots of argument checking and intermediate-value checking, which I do see in C/C++, Java, etc.</p>
  
  <p>In my shop, we're very accustomed to checking arguments &amp; other values and taking early exits when the arguments don't meet contracts / preconditions, etc. For example, consider the following (contrived, imperfect, typical, but please-don't-waste-time-criticizing, micro-example, which presages the CL example):</p>
  
  <pre><code>ErrorCode o_symb_to_g_symb (char * symb, uint len)
  {   if (len &lt; 2) { return ERROR_LENGTH; }
      if (symb[0] != 'O' || symb[1] != '!') { return ERROR_SYNTAX; }
      char * result = (char *) malloc (len + 1);
      if (NULL == result) { return ERROR_MALLOC; }
      if (result != strncpy (result, symb, len + 1)) 
      {   return ERROR_STRNCPY;   }
      result[0] = 'G';
      return result;   }
  </code></pre>
  
  <p>This does approximately the same thing as Doug Hoyte's code from "Let Over Lambda," page 67, only it takes care to check as much as possible along the way (<a href="http://letoverlambda.com/">http://letoverlambda.com/</a>). </p>
  
  <pre><code>  (defun o!-symbol-to-g!-symbol (s)
      (symb "G!"
            (subseq (symbol-name s) 2))))
  </code></pre>
  
  <p>The question is whether real-world production code in Common Lisp does more checking.  For example, it might be reasonable to write explicit code to check that s is actually a string and is actually long enough, and actually has an "O!" as its first two characters.</p>
  
  <p>Is this code bypassing all that paranoia just because it's pedagogical?  Would the same code in a mission-critical production deployment be more likely to have the paranoia checks (my light canvasing of Github for CL code would suggest "no")?  If real-world CL code does not tend to the paranoid, why not?  Is the practice of corner-case or exhaustive testing more widespread than it appears?  </p>
  
  <p>In short, I'm quite puzzled by the difference in styles.  Real-world, mission-critical C code tends to be super-paranoid.  I don't see the same in CL.  Perhaps I'm not looking at the right code bases? Perhaps I haven't read the right books?  An answer to this question doesn't seem to be easy to find by Googling.</p>