Skip to content
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

optional normalizations (loose matching mode) #10

Open
kazcw opened this issue Oct 10, 2018 · 1 comment
Open

optional normalizations (loose matching mode) #10

kazcw opened this issue Oct 10, 2018 · 1 comment
Labels
enhancement New feature or request

Comments

@kazcw
Copy link
Owner

kazcw commented Oct 10, 2018

Structural grepping could benefit from optional normalization so that this pattern:

match $_ { Ok($p0) => $p0, Err($p1) => $p1 } }

Would match both of these:

match x { Ok(a) => a, Err(b) => b } }
match x { Err(a) => a, Ok(b) => b } }

The normalization pass in this case would be: when tracing a node that can have a collection of descendants whose order may not be significant, trace all the children, and then sort the traces (arbitrarily, but consistent for the same content). All optional normalizations are lossy; in this case, no attempt will be made to determine whether e.g. a previous guarded match affects a later match so that rearrangement is semantically effectful.

There are other normalizations that would be useful. The API should support enabling individual normalizations, and also define a standard set to enable for "loose matching mode".

@kazcw kazcw added the enhancement New feature or request label Oct 10, 2018
@kazcw
Copy link
Owner Author

kazcw commented Oct 10, 2018

The loose matching flag would be the interface for structural grep. For lints, etc. explicitness and fine-grained loosening would be preferable. An attribute in the patterns seems like the right interface there:

#[comacro(any_order)]
match $_ { Ok($p0) => $p0, Err($p1) => $p1 } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant