How to create non-abstract subtypes of built-in abstract types? What is the Julia's substitute for Interfaces?

Julia is a duck-typed language and lacks language-enforced interfaces. Since it also contains a number of Abstract classes that user can specialize, I wonder, how do you make sure, that you have provided sufficient number of methods in your specialization? Manual is one source - but it only lists a handful of abstract types.

In particular I miss the description of Range abstract types, i.e. everything that is a supertype of UnitRange.


I need it because I want to understand, how does broadcast work in Julia 1.0.0 and for that I want to define a type with custom axes and want to understand, what exactly class I should specialize. AbstractUnitRange? OrdinalRange? AbstractRange? AbstractArray?

1 Like

For now interfaces are documented.

https://docs.julialang.org/en/v1/manual/interfaces/

Not all abstract interfaces are documented though.

1 Like

Yes, that part I know. Where do I find the documentation of Range type hierarchy? Should I ask the devs?

I do not believe that looking at the source will give me a quick answer, because there is no formal distinction between methods that implement a certain type and methods that only use it.

I am afraid that even the “official” interface of many of the abstract types is underdocumented, eg I recently asked for a clarification about custom indexes, and ended up opening an issue.

This may be the best solution for your problem, but at the same time you should consider the possibility that some of the abstract types are just there to help implementation (particularly, dispatch) and may not define an actual interface other than what the code shows.

1 Like