Write about how coherence makes it nearly impossible to establish standard traits outside of libstd.
Brief summary
Write about how coherence makes it nearly impossible to establish standard traits outside of libstd.
In a nutshell:
- If I define a trait that (say) all runtimes should implement, they obviously won't implement it yet; typically I then have to implement it for them, because they don't want to implement some Random Joe's trait;
- at that point, my trait crate depends on all the runtime crates (albeit with optional features, presumably);
- now those runtimes can't depend on my trait, so they can't implement it, even if they wanted to!
It's sort of a chicken-and-egg problem that seems like it would be quite hard to get around.
Optional details
- (Optional) Which character(s) would be the best fit and why?
- (Optional) Which project(s) would be the best fit and why?
- List some projects here.
- (Optional) What are the key points or morals to emphasize?
- Write some morals here.
Anecdotally, I think this extends beyond just async: imagine trying to introduce a replacement for serde today.
We will touch a little bit on this in #45. I wonder if the exploration in that story is good enough or if a separate story is needed to really drive home the point.
Anecdotally, I think this extends beyond just async: imagine trying to introduce a replacement for
serdetoday.
I had the misfortune of running into something similar with zvariant, where for ser/de to/from the D-Bus format, I need a signature string for the type and hence had to require a trait to be implemented for types that can be ser/de. I provide a derive macro so local types are not a big issue but external types are.
@jonhoo I definitely agree it extends beyond async