Added default attribute to match arms for specialization in nightly#1
Added default attribute to match arms for specialization in nightly#1jerry73204 merged 1 commit intojerry73204:masterfrom
Conversation
|
Thanks that you take a glance on it! I'd like to understand the status of specialization. Seems the RFC-1210 is merged but the implementation is still in its journey. Does it mean that |
|
That's a difficult question to answer. The specialization RFC has been open since 2016 and based on tracking issues marked Based on my experience, There's just too much demand for this feature and it's too powerful, especially with GATs - it just happens to be one of the hardest features to implement. I think it's worth providing nightly features here (at least behind a feature flag) to enable experimentation but I'd hold off on this PR until I've had more time to play with it in my code base (show stopping specialization errors tend to happen at the point of use, not declaration, so you can't know whether a specific design is practical or not until it's too late). At the very least, the way trait bounds are specified on the output ( Side note, have you had a chance to experiment with generic associated types? They landed in nightly in December so its still a very new feature but its critical to trait Func<T> {
type Output<U>;
}
typ! {
fn fmap<t1, t2>(t1: Func, t2: _) {
Func(t1)(t2)
}
} |
|
I will accept nightly and unstable features that are expected to land, and also the typ itself is experimental. I look forward to GAT to land and wonder if it works in recursive type construct. I've been experimenting processing type level lists, for example, pytorch-like broadcast operation (doc) on two dimensions. It's challenging to implement in types. Think of a list of compile-time numbers and dynamic runtime numbers. It should be able to put dynamic checking stubs for dynamic numbers, so you get many cases to deal with. Anyway, feel free to share your mind here. |
Thank you for the great work on this library! It has made type level programming a lot more tractable.
I've added a
#[default]attribute for working with specialization