Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

symmetric difference #5

Closed
markusicu opened this issue Feb 4, 2021 · 7 comments
Closed

symmetric difference #5

markusicu opened this issue Feb 4, 2021 · 7 comments

Comments

@markusicu
Copy link
Collaborator

Should we add an operator for symmetric difference? The Unicode regex spec (UTS #18) suggests it, and a couple of implementations (Python regex module, Perl experimental) support it. It is a standard set operation. However, it is unclear whether there is a practical use case for it.

If we don’t add it now, we may not be able to add it later without compatibility issues/flags/new syntax.

@macchiati
Copy link
Collaborator

It is less important than the others, but still useful to express the differences between sets, without pretty ugly expressions:

\p{Lowercase}\p{Lowercase_Letter}--[\p{Lowercase}&&\p{Lowercase_Letter}]

One option would be to reserve ~~ (maybe a few other doubled ASCII symbols as well) for future extension. That is, at first release they would be syntax errors.

@markusicu
Copy link
Collaborator Author

For inspecting differences between sets, we usually use A-B and B-A, separately. I don't know what to do with the xor.

But there is the opportunity. Now or never... and reserving the syntax is not much less work than actually specifying and implementing it.

I like the idea of reserving further ASCII punctuation/symbols, doubled or not.

@sffc

This comment has been minimized.

@markusicu

This comment has been minimized.

@sffc

This comment has been minimized.

@mathiasbynens
Copy link
Member

I'd prefer to keep this initial proposal as minimal as possible, i.e. exclude symmetric difference. We can — and should — however reserve syntax to ensure we can extend set notation in the future.

reserving the syntax is not much less work than actually specifying and implementing it.

This is by itself not an argument to add a new language feature. We need to make such decisions based on real-world use cases. Since we already have plenty of figuring out to do even without considering symmetric difference, I'd prefer postponing those decisions to a follow-up proposal.

@markusicu
Copy link
Collaborator Author

In PR #13 I added a note about symmetric difference to the propsal FAQ:
https://github.com/tc39/proposal-regexp-set-notation#what-about-symmetric-difference

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants