title: Overloading vs. Overriding in Julia
body: <p>I am not familiar with Julia but I feel like I noticed it allows you to define functions multiple times with different signatures, such as <a href="https://github.com/JuliaAstro/SkyCoords.jl/blob/57e62e8835120483e4f7075d52bc165878aea7b6/src/SkyCoords.jl#L41-L43" rel="nofollow noreferrer">this</a>:</p>
  
  <pre><code>FK5Coords{e}(ra::T, dec::T) where {e,T&lt;:AbstractFloat} = FK5Coords{e, T}(ra, dec)
  FK5Coords{e}(ra::Real, dec::Real) where {e} =
     FK5Coords{e}(promote(float(ra), float(dec))...)
  </code></pre>
  
  <p>To me it looks like this allows you to call <code>FK5Coords</code> with two different signatures.</p>
  
  <p>So I'm wondering (a) if that is true, if Julia allows <a href="https://en.wikipedia.org/wiki/Function_overloading" rel="nofollow noreferrer">overloading functions</a> like this, and (b) if Julia allows something like <a href="https://en.wikipedia.org/wiki/Method_overriding" rel="nofollow noreferrer"><code>super</code></a> in a function, which seems like it would conflict with overloading. And (c), what an example snippet of Julia code looks like that shows (1) overloading in one example, and (2) overriding in the other.</p>
  
  <p>The reason I'm asking is because I am wondering how Julia solves the problem of having both <code>super</code> and function overloading, because both require defining the function again and it seems you would have to flag it with some metadata or something to say "in this case I am overriding" or "in this case I am overloading".</p>
  
  <p>Note: If that was not an example of overloading, then (from Wikipedia) this was what I was imagining Julia supported (along these lines):</p>
  
  <pre><code>// volume of a cylinder
  double volume(const double r, const int h)
  {
      return 3.1415926*r*r*static_cast&lt;double&gt;(h);
  }
  
  // volume of a cuboid
  long volume(const long l, const int b, const int h)
  {
      return l*b*h;
  }
  </code></pre>