Nim supports procedure overloading that allows the implementation of multiple 
procs with the same name distinguished by the signature of their parameters. 
However, it does not seem to be possible to do overloading with explicit 
parameters such as [], "Araq" or 0 as in the following example:
    
    
    proc fib(0): int = 1
    proc fib(n: int): int = n*fib(n-1)
    => Error: redefinition of 'fib'; previous declaration here: 
/usercode/in.nim(1, 6)
    
    
    Run

Is there any reason why this isn't possible in Nim? Languages like Haskell or 
Elixir go through all functions / procedures from top to bottom and choose the 
first implementation that matches
    
    
    defmodule Foo do
      def fib(0), do: 1
      def fib(n), do: n*fib(n-1)
    end
    
    IO.puts Foo.fib(6)
    => 720
    
    
    Run

Reply via email to