On Thu, Nov 21, 2013 at 5:01 PM, abbed Idriss <
orcasar...@gmail.com> wrote:
> I see where your coming from if we were talking about something completely
> new and untested. But function overloading has been tested in many many many
> languages and has been shown to work just fine.
This is not a question about if function overloading could be made to
work in Go. Clearly it could be made to work, but at a cost. The cost
that everyone is reminding you of is complexity.
Earlier in this thread Jesse gave a concrete example (which you
ignored) of where allowing function overloading would make Go more
complicated, not just from the compiler authors point of view, but for
people writing and using Go code.
func SomeFunc(a io.Writer, b io.Reader)
func SomeFunc(a io.Reader, b io.Writer)
var foo io.ReadWriter
var bar io.ReadWriter
SomeFunc(foo,bar) // which version of SomeFunc is called ? The first,
the second ?
This is an excellent example of how adding function overloading to the
language adds ambiguity, which lead to fiat rules defined in a spec,
rather than flowing cleanly from a design.
To that end, the language authors made a _choice_ not to implement
function overloading (or operator overloading for that matter) to
simplify the language, for the writer, the compiler author, but most
importantly the reader and user of Go code.
Dave
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
golang-nuts...@googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.