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

Add support for ignoreable patterns #45

Merged
merged 2 commits into from
May 20, 2024

Conversation

ltratt
Copy link
Member

@ltratt ltratt commented May 20, 2024

One irritation with fm is that if you need to match (potentially or definitely) different literal text in a pattern, you need to generate fresh pattern names for each match point, even though you're not comparing the contents of these names. For example, if you want to match against the text "a b" you might use a pattern $1 $2 (note: $1 $1 would not match).

This commit adds support for "ignorable" name matches, which match against literal text, but ignore what the contents are. For example, if you add $_ as the ignorable pattern matching literal text then you can match against a b with $_ $_.

I'm not sure if name_matcher_ignore is the best name for the relevant configuration function, but at the very least it shows what this functionality can do, and that it's relatively easy to add in.

One irritation with fm is that if you need to match (potentially or
definitely) different literal text in a pattern, you need to generate
fresh pattern names for each match point, even though you're not
comparing the contents of these names. For example, if you want to match
against the text "a b" you might use a pattern `$1 $2` (note: `$1 $1`
would not match).

This commit adds support for "ignorable" name matches, which match
against literal text, but ignore what the contents are. For example, if
you add `$_` as the ignorable pattern matching literal text then you can
match against `a b` with `$_ $_`.

I'm not sure if `name_matcher_ignore` is the best name for the relevant
configuration function, but at the very least it shows what this
functionality can do, and that it's relatively easy to add in.
These can only really catch crashes in fm's code, but that's better than
nothing.
@vext01
Copy link
Member

vext01 commented May 20, 2024

I've not looked at the code, but I'm in favour :)

About the name, some ideas, how about "anonymous matches"?

@ptersilie ptersilie added this pull request to the merge queue May 20, 2024
@ptersilie ptersilie removed this pull request from the merge queue due to a manual request May 20, 2024
@ptersilie
Copy link
Member

name_matcher_ignore sounds fine to me, but I'll wait with the merge for now in case there's some discussion on this.

@ltratt
Copy link
Member Author

ltratt commented May 20, 2024

I don't feel too strongly about it. I don't intend making a new fm release for a little bit, so if a better name does occur to us, we can come back and change this without breaking the public API.

@ptersilie ptersilie added this pull request to the merge queue May 20, 2024
Merged via the queue into softdevteam:master with commit bf4cf6c May 20, 2024
2 checks passed
@ltratt ltratt deleted the ignoreable_pattern branch June 3, 2024 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants