title: What are Elixir Bang Functions?
body: <p>I first noticed a function with a trailing exclamation-mark/bang(!) while going through the Phoenix tutorial (in the <a href="http://www.phoenixframework.org/docs/channels#section-incoming-events">Incoming Events</a> section) </p>
  
  <pre><code>def handle_in("new_msg", %{"body" =&gt; body}, socket) do
      broadcast! socket, "new_msg", %{body: body}
      {:noreply, socket}
  end
  </code></pre>
  
  <p><strong>What does the trailing exclamation mark mean?  Does it do anything?</strong> I've been searching around and tried looking but I'm not sure I'm using the right terms.  So far it seems that the function only as convention will raise an error if it fails, but does always it always mean that.</p>
  
  <p>The only mentions I see of it appear in "Programming Elixir" by Dave Thomas:</p>
  
  <pre><code>Identifiers in Elixir are combinations of upper and lower case ASCII 
  characters, digits, and underscores. Function names may end with a 
  question mark or an exclamation point.
  </code></pre>
  
  <p>And also in <a href="http://elixir-lang.org/getting-started/io-and-the-file-system.html">the documentation</a> it mentions:</p>
  
  <pre><code>Notice that when the file does not exist, the version with ! raises an
  error. The version without ! is preferred when you want to handle
  different outcomes using pattern matching...
  </code></pre>
  
  <p>Neither of these explains if this is a convention that other elixirists or alchemists or whatever use. Please help.</p>