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

subtract a not-proper-subset #32

Closed
@markusicu

Description

@markusicu

In the TC39 meeting this week (2021-may-26) someone asked what happens in subtraction A--B when B is not a proper subset of A.

  • My response was that this would be fine, just like in math, and that this is how people implement sets in general in computers. {ab}--{bc}={a}
  • The person asking felt like this is somehow different from math sets and might mask a bug in the pattern.
  • Mathias responded that it's important to support such a case, so that a regex author can make sure that a character class definitely does not match a certain set of things, without jumping through hoops to make sure that that is a proper subset. (This could require a nested intersection with the left-side set: [A--[B&&A]] rather than just [A--B].)

In my mind, character classes define sets in the mathematical sense, and set operations should behave as usual. From the current spec: “A CharSet is a mathematical set of characters.” and the semantics evaluate a CharacterClass and a CharacterClassEscape to a CharSet, using union operations as appropriate (“Return the union of ...”).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions