-
Notifications
You must be signed in to change notification settings - Fork 161
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
Change HIR visitor pattern #3160
Comments
Hi, I recently encountered this issue and reached the same opinion that walk and visit should be separated.
Do you mean mutating AST nodes by "infix" operations? |
We really need to be sure to where we're heading so I'll put a maximum of informations here from what has been discussed previously:
Our trees are quite big, this means any move will take some time to implement and will be tedious. |
for what it's worth I'm not sure this is a good idea considering C++. this pattern works very well in Rust because move semantics are the default, and make sense. but it is a lot more annoying to do in C++ I really think that having separate walks and visits functions could clean things up, but it would be a huge change |
For now we should probably focus on the initial goal of this PR: provide a default visitor, we'll then be able to move it to some walk funcitons in another issue/pr. |
@P-E-P Can you assign it to me ? |
HIR is in a bad state, multiple efforts could be started to improve the current situation. One of those could reduce the amount of code by removing boilerplate code within HIR visitors.
Most visitors currently have to redefine over and over traversal functions even when the visitor per se should only act on a few components.
Some proposals have been made to improve the general state of visitors within the project:
#[derive]
attribute is used on a compatible item #2904 (comment)In the long run we should probably separate visit from walk in all our visitors but this requires an extensive refactor of multiple parts of the code base and multiple question remains (some AST visitors require infix operations).
We already provide an interface for HIR visitors:
HIRFullVisitor
.ASTDefaultVisitor
,ASTVisitor
,ASTContextualVisitor
...)The text was updated successfully, but these errors were encountered: