tadeuzagallo / verve-lang

A functional language for the working hacker
https://verve-lang.org
MIT License
346 stars 7 forks source link

Should function overloading be allowed? #20

Closed tadeuzagallo closed 8 years ago

tadeuzagallo commented 8 years ago

Should the following be valid?

substr(String, Int): String
substr(String, Int, Int): String

Or is it more idiomatic to have something like:

type Range = Range(Int, Int) || From(Int)

substr(String, Range): String

/cc @jspahrsummers

jspahrsummers commented 8 years ago

Overloading almost always causes more problems than it solves. It makes type unification exponentially more expensive, for one.

I like your second example there. If someone really wants overloading, they can use a type class (which is just like inverted overloading).

tadeuzagallo commented 8 years ago

Yeah, I convinced myself of the same as I wrote the non-overloading option, just wanted to hear your thoughts on it. Thanks!