Skip to content

Offer an option for type-stability of re_matches() #94

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

Open
MichaelChirico opened this issue Oct 27, 2024 · 0 comments
Open

Offer an option for type-stability of re_matches() #94

MichaelChirico opened this issue Oct 27, 2024 · 0 comments

Comments

@MichaelChirico
Copy link
Contributor

More than once now, we've run into an issue caused by type-instability of re_matches() output (logical vector vs. data.frame).

r-lib/lintr#196
r-lib/lintr#2287
r-lib/lintr#2678

At root, if we're writing functions taking regular expressions with re_matches() as a backend, it's hard to anticipate whether the user will use capture groups (or vice versa), and it can be hard to remember the need to branch the follow-up code depending on whether we received a data.frame.

Much better IMO to offer a path for type-stability directly in the re_matches() API (much like simplify=FALSE in *apply world). Maybe ignore_capture_groups (FALSE by default), then we can write code with ignore_capture_groups=TRUE to guarantee a logical return.

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

No branches or pull requests

1 participant