On Thursday, April 30, 2015 at 1:11:27 PM UTC-4, Tom Breloff wrote:
>
> I agree that it would be really nice, in some cases, to auto-merge
> function definitions between namespaces (database connects are very simple
> OO example). However, if 2 different modules define foo(x::Float64,
> y::Int), then there should be an error if they're both exported (or if not
> an error, then at least force qualified access??) Now in my mind, the
> tricky part comes when a package writer defines:
>
> module MyModule
> export foo
> type MyType end
> foo(x::MyType) = ...
> foo(x) = ...
> end
>
I think this is a very interesting discussion, but it all seems to come
back to a human communication issue. Each package author must *somehow*
communicate to both users and other package authors that they mean the same
thing when they define a function that's intended to be used
interchangeably. We can either do this explicitly (e.g., by joining or
forming an organization like JuliaStats/StatsBase.jl, JuliaDB/DBI.jl,
JuliaIO/FileIO.jl, etc.), or we can try write code in Julia to help mediate
this discussion.
The heuristics you're proposing sound interesting (and may even work,
especially when combined with delaying ambiguity warnings and making them
errors at an ambiguous call), but I have a hunch that it will take a lot of
work to implement. And I'm not sure that it really makes things better.
Bad actors can still define their interfaces to prevent others from using
the same names with multiple dispatch (e.g., by only defining
`connect(::String)`). Doing the sort of automatic filetype dispatch (like
FileIO is working towards) still needs *one* place where `load("data.jld")`
is interpreted and re-dispatched to `load(::FileType{:jld})` that the
HDF5/JLD package can define its dispatch on. Finally, one currently
unsolved area is plotting. None of the `plot` methods defined in any of
the various packages are combined into the same function, nor could they
feasibly do so without massive coordination between the package authors
(for no real functional gain). This proposal doesn't really solve that,
either. It'll be just as impossible to do `using Gadfly, Winston` and have
the `plot` function just work.
I hope this doesn't read as overly negative. I think it's great that folks
are pushing the edges here and proposing new ideas. But I'm afraid that
this won't replace the collaboration needed to get these sorts of
interfaces working well and interchangeably.