Hello everyone,
I am interested in picking up the “what to implement problem” of defining interfaces/protocols in Julia. In my view the broad issue is: How do I encode invariants and expectations of my code. This is critical both at the point of use of my package, and for reasoning about its internal structure. How do we use this encoding to help the user correctly use it (good error messages, REPL discoverability), and me as author to completely document it (doc strings, tests).
The dynamicism and multiple dispatch of Julia, that enables all the immense goodness and composability we get from it, also makes the above points challenging.
For my research group this is a much bigger issue than, e.g. compilation times right now. Compilation times can be worked around, but this lack of structure in Julia code-bases is often a real showstopper. (And the often inscrutable error messages that I believe are also linked to this are a major issue in teaching it to new students.).
I have no intention to fully solving this issue, that would only be possible with buy-in from the core team and the standard library, and that will probably mean this is something for Julia 2.0 (though i really hope I am wrong about this). But I want to start contributing by prototyping things I think could be useful in this direction. I also hope that by prototyping in this direction we can gain a bit of experience with how protocols et.al. interact with other aspects of Julia.
I wrote up a gist summarizing my thinking on where I want to go with this here.
The basic idea is to build on top of Holy style traits, guaranteeing [1] that a type that has a certain trait also has certain fields and functions defined on it. Further, this should not be automatically detected but require explicit declaration (Rust Traits rather than C++ Concepts).
I would be interested in feedback but also general input and discussion. And I probably overlooked ongoing discussion/prototypes/implementations somewhere, which is another reason why I am posting before having code to show.
[1] In a weak sense: Unless the user manually uses the underlying trait that is not exposed anywhere. But Julia is fully dynamic anyway. The goal is to make the happy path the obvious one, not the only one.