-
Notifications
You must be signed in to change notification settings - Fork 175
Support tracked associated functions #858
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
Comments
This is already supported. You can add a salsa::tracked attribute to an impl block and you can then mark specific methods as tracked. What's currently not supported is methods without a self argument but that restriction should be easy to lift |
That's exactly what I'm proposing. 😊
And I already have a working branch that I'll open a PR for in a bit. |
I think this is the same as #585 |
Oh, no. How the heck did I miss that when searching? Feel free to close as duplicate then. |
In #319 @nikomatsakis motivated the introduction of support for tracked methods (i.e. associated functions with a
self
argument).I would like to propose extending this to type-level associated functions (i.e. without
self
argument) as well.Tracked associated functions would have to follow the same function signature rules as their equivalent free functions.
As such the following:
… could be rewritten as such:
While I'm using a "constructor" function here as a motivational example, they are obviously merely one of may use cases for tracked associated functions.
As such support for tracked associated functions would allow for neatly grouping tracked functions into (even untracked, and otherwise unrelated) types:
The
OutputGenerator
type kind of like acts like a "namespace" type here, but with additional benefits (for those who need id), such as providing the tracked functions access to its associated types (a major limitation of free functions in a "namespace" module).I'd argue that tracked associated functions would not only fill a gap in salsa's current expressivity, they also tend to feel more idiomatic and and support for semantic grouping (beyond merely showing functions in a common module) makes the code look more cleaned up overall.
The text was updated successfully, but these errors were encountered: