-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Traits #5
Comments
Absolutely love this one, the more information we have within ddlog (and by extension, the more information the compiler has access to) the better
I think it's worth noting that this isn't actually strictly related to traits, we could feasibly detect what plumbing traits are required automatically, this could be a really substantial compile time and binary size gain though, great idea!
I'd imagine this is about the same level of complexity as exposing ddlog functions to dynamic code as well, so it may be a moot point |
Automatic detection is not always possible, since the code that invokes these traits can be on the client side (e.g., serialization).
You're right, and I have to admit I don't know how to do either well :) |
Traits are great, we'd love to have them in P4 too, but if we don't know how to implement them, the question is academic. |
No idea what the complexity is. |
Then clearly the answer is: "we won't do it in the first version of the new implementation." |
I think we should figure out how to do it properly, including inference algorithm. |
Added another item in pros:
|
We don't need traits for that. Today our generics are more like c++ templates, checked at use time. They work fine for most uses. You can start with templates and convert them to traits later hopefully. |
Let's say you wanted to implement a transformer that generalizes recursive path computation, but would like to make it generic in the
How would you do this without generics? |
I said that you need generics but not yet traits |
Fair enough. My thinking is, we should do it properly if we can. |
I am saying that we don't need to do it right away, there is a way to start with templates and convert them to traits when we know how to do it. |
I understand, and I don't agree this is a good approach :) |
If you don't know how to do it it may be the only approach. |
I mean we could also learn how to do it, but I guess that's crazy talk :) |
You have ~100 things that you need to do, the question is not whether you can do it, but where do you put it in the list and how much it will block the items after it in the list. |
That is true, we need to evaluate the complexity and decide if it's worth it. |
Rust's new trait solver: https://rust-lang.github.io/chalk/book/what_is_chalk.html |
If the API of this solver is general-purpose perhaps it can be just reused. That would be great. |
I am staring to read up on it. It apears to be rust-specific. But internals might still be reusable. |
I've been reading about chalk and the underlying theory. I believe we should be able to reuse the solver component of chalk by encoding our type system in the IR supported by the solver (the encoding is described in chalk book). Theoretically, the encoding part can be reused as well, but that may pull in too many Rust dependencies. |
Minutes of meeting (Sep 23, 2021):
|
No design proposal yet. Just collecting pros and cons of adding support for traits (or some other form of generics) to the language.
Why supporting generics (traits) is a good idea
extern
functions that require such bounds must be declared without trait bounds in DDlog. Calling such a function with an argument that does not satisfy the bounds causes Rust compilation errors.Serialize
/Deserialize
for a subset of types. Same goes forFromRecord
,ToRecord
,Mutator
.Why traits are a bad idea
#[derive]
attribute that will tell DDlog that the type implements the trait, but will delegate the actual implementation to Rust.The text was updated successfully, but these errors were encountered: