-
Notifications
You must be signed in to change notification settings - Fork 624
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
wire: do not use global variables for all wire.Value expressions #185
Comments
The reason we have the semantics we have now for It sounds like the request here is that the generated code in some circumstances (like when using a constant expression, for example) could be more efficient, since the time that the expression is evaluated wouldn't matter. That seems reasonable to me, but I think we can add this feature in a backward-compatible way later. |
Yes, but it's not just about efficiency. One of the selling points of wire is that the generated is a readable representation of the dependency setup. This is one thing that makes the code less idiomatic/readable |
Agreed. To be clear: I think this is a good idea, but we don't have bandwidth to fix it right now. Happy to review PRs to fix. |
I'll take a stab at this. |
@zombiezen A few observations here.
Since this issue is still open, I decided to try it out and it works but it's only a local test change (not confident if that's the solution we are looking for), Thank you |
One of the specific advantages of the wire approach is that it generates code that's relatively readable compared to reflect-based equivalents. When
wire.Value
is used on a small by-value type, there's no need for the value to live in a global variable - the expression could instead be used literally inside the generated code, which would make the code easier to follow, and more similar to the code that one might write by hand.The text was updated successfully, but these errors were encountered: