You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've found myself in the position where I've hacked a local copy of this library to support the PCRE2_MULTILINE option. I think it might be nice to let users pick and choose options when compiling patterns, but I'm not sure about the best way to do that.
Creating primitives and using collections.Flags might be one way, but that would necessitate passing another argument to Regex.create(), which raises the issue of positioning the argument. flags before jit breaks compatibility with existing code. flags after jit means that any user who wants to set flags would have to also choose whether or not to jit-compile the pattern, adding boilerplate.
Another option might be to absorb the jit argument into a Flags object, but that would also break compatibility.
One way to not break compatibility or add boilerplate might be to expose fun ref pattern_options() ?, but that method would have to recompile the pattern, which is a bit of a waste.
Exposing something like new with_opts(from: ByteSeq box, jit: Bool = true, flags: PCRE2Flags = ...) seems like a good option. It's my favorite at the moment.
I'm open to other ideas, and I'd be glad to contribute this enhancement once I have a better idea of what we want for this library.
The text was updated successfully, but these errors were encountered:
Since the jit argument has a default value (true), putting the flags argument after jit, and giving a default value, would be my preferred option. Users who only want to change the flag, but not the jit can do Regex.create(string where flags = ...)
I've found myself in the position where I've hacked a local copy of this library to support the
PCRE2_MULTILINE
option. I think it might be nice to let users pick and choose options when compiling patterns, but I'm not sure about the best way to do that.collections.Flags
might be one way, but that would necessitate passing another argument toRegex.create()
, which raises the issue of positioning the argument.flags
beforejit
breaks compatibility with existing code.flags
afterjit
means that any user who wants to set flags would have to also choose whether or not to jit-compile the pattern, adding boilerplate.jit
argument into aFlags
object, but that would also break compatibility.fun ref pattern_options() ?
, but that method would have to recompile the pattern, which is a bit of a waste.new with_opts(from: ByteSeq box, jit: Bool = true, flags: PCRE2Flags = ...)
seems like a good option. It's my favorite at the moment.I'm open to other ideas, and I'd be glad to contribute this enhancement once I have a better idea of what we want for this library.
The text was updated successfully, but these errors were encountered: