News for hackers. Stuff that matters.
Re:Using Recursion in Elixir by speedkills on Sunday September 06, 2015 @11:52AM (#10177964)
Serious question, is pattern matching in Elixir any different from overloading?
Re:Using Recursion in Elixir by ericmj on Sunday September 06, 2015 @12:25PM (#10178071)
Pattern matching and function overloading based on types are different but can be used for the same purposes.

For function overloading the decision for which implementation to use usually happens at compile time along with the type checking. Pattern matching happens at runtime but is more powerful since you can pattern match based on you guessed it: patterns, instead of just types.

Another small difference is that with overloading multiple functions with different signatures are created (they just share name) but with pattern matching there is a single function with multiple "function clauses".

Re:Using Recursion in Elixir by speedkills on Sunday September 06, 2015 @12:48PM (#10178148)
Great explanation. Thank you.
Re:Using Recursion in Elixir by zzalpha on Sunday September 06, 2015 @04:49PM (#10178950)
To provide a shorter answer: polymorphism dispatches on types at compile time. Pattern matching dispatches on values at runtime.