-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Simplify logic in StringifyTypeExpr
using push_string
#4561
Conversation
out << ">"; | ||
} | ||
out << "<associated "; | ||
push_string(">"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to infer from reading that these push statements are executed in reverse order (FILO), though I was confused for a minute :) Do you think we could add a comment on push_string and push_inst_id saying so to help future readers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it have been enough if steps
were named steps_stack
, to emphasize the stack behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, something in the name calling out would be nice as an alternative
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though I suppose that would have mostly helped in this diff from seeing it in the deleted lines. It doesn't appear really in the text otherwise as it's being bound into the lambdas, but it would be found when reading the lambdas (in place of a comment on them), which would indeed be better than having to reverse engineer it a bit more. Anything helps :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I talked about this with @zygoloid , and he suggested we could make push_string
, push_inst_id
, and push_specific_id
into methods on a "work stack" object, which would hopefully address this concern. I would be happy to do that in a follow-up PR, because that work is largely independent of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the meantime, I've added some comments to the push_
* functions about the order reversing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems reasonable for now. The subsequent refactoring does seem like another useful improvement.
We have a lot of stack-ish worklists, but this one is surprisingly critical to work that way to make it do the right thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG, this seems like in a good state and a significant improvement over the state before. Good idea inline for a further refactoring.
out << ">"; | ||
} | ||
out << "<associated "; | ||
push_string(">"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems reasonable for now. The subsequent refactoring does seem like another useful improvement.
We have a lot of stack-ish worklists, but this one is surprisingly critical to work that way to make it do the right thing.
…guage#4561) Follow-on to carbon-language#4511. --------- Co-authored-by: Josh L <[email protected]>
Follow-on to #4511.