New Issue: Should tertiary methods be defined for regexp?

17226, "leekillough", "Should tertiary methods be defined for regexp?", "2021-02-22T22:07:00Z"

Should tertiary methods be defined for regexp?

Method Description
proc string.search(needle: string, ignorecase=false):reMatch Search for needle regexp in string
proc bytes.search(needle: bytes, ignorecase=false):reMatch Search for needle regexp in bytes
proc string.search(needle: regexp(string)):reMatch Search for a compiled regexp in string
proc bytes.search(needle: regexp(bytes)):reMatch Search for a compiled regexp in bytes
proc string.match(pattern: regexp(string)):reMatch Match a regexp to string
proc bytes.match(pattern: regexp(bytes)):reMatch Match a regexp to bytes
proc string.match(pattern: regexp(string), ref captures ...?k):reMatch Match a regexp in string, returning captures
proc bytes.match(pattern: regexp(bytes), ref captures ...?k):reMatch Math a regexp in bytes, returning captures
iter string.split(pattern: regexp(string), maxsplit: int = 0) Split string with regexp
iter bytes.split(pattern: regexp(bytes), maxsplit: int = 0) Split bytes with regexp
iter string.matches(pattern:regexp(string), param captures=0, maxmatches:int=max(int)) Returns matches and captures on string
iter bytes.matches(pattern:regexp(bytes), param captures=0, maxmatches:int=max(int)) Returns matches and captures on bytes
  • Do we want to define tertiary methods which operate on string and bytes, or should we keep the number of interfaces smaller, and only provide methods on regexp class?

    The methods on regexp are generic, and work for either string or bytes, while the tertiary methods have to be defined for string and bytes separately, but they are usually just wrappers to the generic regexp methods.

  • Do we want to provide methods which compile regular expressions "on the fly" (caching the compiled result), or should we require the user to compile the regexp separately?