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
This library follows an old established pattern. It vends out constants to be used. These constants are globally available, kept in a namespace for organization sake (RegexLiterals and RegexBuilders). However, this pattern is no longer recommended. It is a warning in Swift 5.10 when using Strict Concurrency, and it is a non-compiling error when using Swift 6.
This happens because Regex and RegexComponent are not Sendable. My understanding is that they are not Sendable because the Swift Regex engine allows users to insert custom logic, therefore, the compiler can't know ahead of time if it is concurrency safe.
For this reason, I created RegexActor, a global actor to isolate the Regexes. RegexActor is empty, stateless, and only exists to provide an isolation context.
I suspect this might not be the best option available. For example, suppose someone already has an isolation context that they would prefer to use. With this solution, I'm not sure if that would be possible or viable. I would love to hear if anyone has any better solutions.
Possible Solutions to Explore
It's possible that we might be able to create an AnyRegexComponent that is a concrete Sendable type. If so, this might fix our problem.
For more context, see: https://iosdev.space/@dandylyons/113057848940742967
This library follows an old established pattern. It vends out constants to be used. These constants are globally available, kept in a namespace for organization sake (
RegexLiterals
andRegexBuilders
). However, this pattern is no longer recommended. It is a warning in Swift 5.10 when using Strict Concurrency, and it is a non-compiling error when using Swift 6.This happens because
Regex
andRegexComponent
are notSendable
. My understanding is that they are notSendable
because the Swift Regex engine allows users to insert custom logic, therefore, the compiler can't know ahead of time if it is concurrency safe.For this reason, I created
RegexActor
, a global actor to isolate the Regexes.RegexActor
is empty, stateless, and only exists to provide an isolation context.I suspect this might not be the best option available. For example, suppose someone already has an isolation context that they would prefer to use. With this solution, I'm not sure if that would be possible or viable. I would love to hear if anyone has any better solutions.
Possible Solutions to Explore
It's possible that we might be able to create an
AnyRegexComponent
that is a concreteSendable
type. If so, this might fix our problem.For more context, see: https://iosdev.space/@dandylyons/113057848940742967
Extra Context
The text was updated successfully, but these errors were encountered: