title: How does functional programming avoid state when it seems unavoidable?
body: <p>Let's say we define a function <code>c sum(a, b)</code>, functional programming -style, that returns the sum of its arguments. So far so good; all the nice things of FP without any problems.</p>
  
  <p>Now let's say we run this in an environment with dynamic typing and a singleton, stateful error stream. Then let's say we pass a value of <code>a</code> and/or <code>b</code> that <code>sum</code> isn't designed to handle (i.e. not numbers), and it needs to indicate an error somehow.</p>
  
  <p>But how? This function is supposed to be pure and side-effect-less. How does it insert an error into the global error stream without violating that?</p>