title: Polymorphism by function parameter
body: <p>Ok - this may be a very stupid question, but it's been bothering me.</p>
  
  <p>Is there a language where</p>
  
  <pre><code>class Animal;
  class Ape : public Animal
  {...}
  
  void doStuff(Animal* animalPtr)
  {
      cout &lt;&lt; "doing animal stuff" &lt;&lt; endl;
  }
  
  void doStuff(Ape* apePtr)
  {
      cout &lt;&lt; "doing ape stuff" &lt;&lt; endl;
  }
  
  Animal *ape = new Ape();
  doStuff(ape);
  </code></pre>
  
  <p>would yield <em><code>"doing ape stuff"</code></em>? (please bear with me using C++ syntax)
  To clarify, I want "a function that accepts an argument and acts on it according to the type of the argument".</p>
  
  <p>And would it make sense? Of course, as a developer you'd need to take care since instances that look just like an Animal pointer might actually call Ape code, because at runtime it's an Ape instance being pointed to.</p>