The current situation is deliberate, see http://julialang.org/manual/types/,
paragraph 4.
I had no role in designing julia, but to perhaps save the core developers from
having to repeat themselves too often, I'll throw in my 2cents about this
issue. In my own experience, I was initially a bit skeptical, and I still
occasionally find myself thinking "oh, I could solve this better with
inheritance." But so far, each time I've thought it through I've found another
way, for example by putting more of the work for a constructor into a separate
function and having multiple types make use of that function. This type of
thinking reduces some of the negatives of not having inheritance. Furthermore,
I have personally experienced some of the problems associated with
inheritance, and I agree that julia's design avoids those traps. So I, at
least, am content with the current situation.
Best,
--Tim
I'm not entirely against the idea of interfaces, but I think that given Julia's multiple dispatch nature the whole concept would need serious reconsideration. It would be nice to be able to know whether you've implemented all the functionality you're expected to implement for something without having to exercise code that triggers that particular error. On the other hand, when developing some functionality, it's really nice to be able to implement an interface incrementally.
On Apr 9, 9:20 pm, Jeff Bezanson <jeff.bezan...@gmail.com> wrote:Then what is the problem with multiple inheritance? My impression has
> Method ambiguities are already possible in our system due to multiple
> dispatch, and we handle it by printing a useful warning.
been that the core team has found it problematic in some way.
> The idea of adding syntax for defining interfaces is too bureaucraticIt doesn't have to be new syntax. If Julia had the right reflection
> for our taste. If an interface requires certain methods, our approach
> is to define default methods on the abstract (interface) type that
> throw errors.
capabilities, presumably you could write a macro that would run any
desired checks. Use of the macro would be optional -- you could do
your incremental development, and then use the macro to check, to the
extent possible, compliance with the expected interface.
There is one other problem I'm still worried about. Suppose a user
defines a method for a function f. Unknown to the user, f is also used
in the standard library, either as an internal implementation detail
or explicitly documented. This breaks some behavior of the standard
library, and suddenly all sorts of strange errors are occurring and
the user has no idea why.
Now that I think about it some more, it seems to me that namespaces
might solve this problem, if they're designed carefully. Someone using
a library would know that they're asking for trouble if they go
defining functions/methods in the library's namespace (except where
the library documentation explicitly states that it's safe.)