On Thu, Apr 30, 2015 at 12:19 PM, Michael Francis <[email protected]>
wrote:
> My goal is not to remove namespaces, quite the opposite, for types a
> namespace is an elegant solution to resolving the ambiguity between
> different types of the same name. What I do object to is that functions
> (which are defined against user defined types) are relegated to being
> second class citizens in the Julia world unless you are developing in Base.
> For people in Base the world is great, it all just works. For everybody
> else you either shoe horn your behavior into one of the Base methods by
> extending it, or you are forced into qualifying names when you don't need
> to.
>
There's nothing privileged about Base except that `using Base` is
automatically done in other (non-bare) modules. If you want to extend a
function from Base, you have to do `Base.foo(args...) = whatever`. The same
applies to functions from other modules. The Distributions and StatsBase
packages are good examples of this being done in the Julia ecosystem. What
is wrong with having shared concepts defined in a shared module?
> 1) Didn't that horse already bolt with Base. If Base were subdivided into
> strict namespaces of functionality then I see this argument, but that isn't
> the case and everybody would be complaining that they need to type
> strings.find("string")
>
I don't understand how any horses have bolted – Base is not particularly
special, it just provides a default set of names that are available to use.
It in no way precludes defining your own meanings for any names at all or
sharing them among a set of modules.
2) To me that is what multiple dispatch is all about. I am calling a
> function and I want the run time to decide which implementation to use, if
> I wanted to have to qualify all calls to a method I'd be far better off in
> an OO language.
>
This is exactly what happens, but you have to first be clear about which
function you mean. The whole point of namespaces is that different modules
can have different meanings for the same name. If two modules don't have
the same meaning for `foo` then you have to clarify which sense of `foo`
you intended. Once you've picked a meaning of `foo`, if it is a generic
function, then the appropriate method will be used when you call it on a
set of arguments.