Swift Pitch: Predicates
We propose creating a new value type,
Predicate
, as part of the FoundationEssentials package, that addresses these problems. These new constructions of predicates will be expressed using standard Swift syntax elements and are fully type-checked by the compiler. This allows us to designPredicate
to be type safe, readily archivable andSendable
, and integrated with Swift development environments.
Aside from type-safety with respect to the object being tested, this could also potentially address the problem where it’s not clear which APIs support which types of NSPredicate
s.
Debbie Goldsmith and Jeremy Schonfeld:
The current design proposes that any developers that need to expand or restrict the set of allowed expressions in their predicate-accepting APIs need to declare their own predicate types with corresponding macros.
Previously: