2022-07-29 –, Purple
When WhereTraits.jl was published 2 years ago, the key missing feature was to address ambiguations between traits function definitions. It is implemented now!
If you as a user encounter a trait conflict, you are now prompted with a concrete example resolution. You simply specify an ordering between the traits and everything is resolved automatically for you.
A feature only available in WhereTraits - even normal julia functions cannot do this.
Method disambiguation is one of the top julia problems which can become tricky to resolve. This is especially true, if one of your dependent packages defined one conflicting part, and another package defined the other part. As a user, you just want to say that the one function should be used instead of the other. Unfortunately, that is not possible, and instead you have to look into the actual source code and implement a resolution yourself.
The same problem occurs to traits, and maybe even more pronounced. If your function has two different traits specializations, let's say one for MyAwesomeTrait
and another for GreatGreatTrait
, it is unclear what to do if your type is both a MyAwesomeTrait and a GreatGreatTrait. You will get exactly such a Method Disambiguation Error.
WhereTraits.jl resolved this difficulty in its most recent release by adding extra support for an ordering between traits, which is used for automatic disambiguation. I.e. the user gets exactly the mentioned power of deciding that the one trait should be preferred over the other. And all this without any performance penalty. The disambiguation system is defined such that traits definition and traits ordering can be in different packages and can be defined multiple times, making the system very flexible and generic.
This new feature is outstanding as even normal Julia function dispatch does not support it.
In this talk I am going to present this new feature, and explain how it is implemented.
Stephan Sahm founded Jolin.io, an IT consultancy for high-performant data/ml pipelines powered by Julia. He also organises the biggest Julia meetup in Germany, Julia-User-Group-Munich.
With 10 years experience in data science and 5 years in IT consultancy and data-startups, he strives to bring tomorrows best practice into todays business.
Julia packages developed by Stephan Sahm: Continuables.jl, WhereTraits.jl, ExprParsers.jl, TypeClasses.jl, ExtensibleEffects.jl and more.