title: Why does Perl allow functions to be declared without being defined?
body: <p>Perl has a notion of an undefined function. A function that's declared but not defined.</p>
  <pre><code>sub foo;
  foo(); # Undefined subroutine error
  bar(); # Undefined subroutine error
  </code></pre>
  <p>This function <code>foo</code> exists now in the symbol table and it can be used to resolve a method call. But why does this &quot;feature&quot; even exist? In C, it's because functions are type-checked and sometimes you want to have a call before you define (such as to resolve a circular dependency). But Perl has no such feature and all function symbols are resolved in runtime not compile time.</p>
  <ul>
  <li><p>If it's for prototypes, then why should an undefined function exist if it does not have a prototype?</p>
  </li>
  <li><p>If it's not for prototypes, why does it exist at all?</p>
  </li>
  <li><p>And why is that undefined subroutines are used in method resolution? Why not ignore them entirely -- you can't call them and they're internal implementation details as far as I can see (<em>at best</em>)? That is why if function isn't defined can't we continue method resolution as if it did not exist <a href="https://stackoverflow.com/q/70834431/124486">(it seems like it would be less confusing)</a>.</p>
  </li>
  </ul>