Open gdalle opened 1 year ago
I have been looking at RequiredInterfaces.jl which seems like an option as well. Given that the Graphs interface is quite complex, I am in favour of using some interface package to check for correct implementations. RequiredInterfaces.jl also adds a NotImplementedError
which could be used instead of the simple Error: not implemented
.
Yeah since I opened this issue I experimented with RequiredInterfaces and was very satisfied. I would love to see it in action here, plus the customer support I got from the lead dev was top notch. Once the first PR is merged I'll try to add it
I'm also curious as to whether traits are actually needed or not. Some are used for dispatch, like is_directed
, but some others just forbid operations that could also be prevented with an explicit error.
Regarding drawbacks of traits:
When we define the new API, there will be abstract types with some methods that must be implemented. In base Julia, I see two main ways of specifying this (as in, defining the function name, possibly with a generic docstring):
I believe a methodless function is better than a single method throwing an error by default. The end result is nearly the same in terms of user experience, but I find the first error clearer because it directly tells you what to implement. @simonschoelly what do you think?
Of course we could also consider more advanced options like Interfaces.jl or InterfaceSpecs.jl but maybe it's a bit overkill?
See also: https://github.com/JuliaGraphs/Graphs.jl/pull/262