{"id":37886,"date":"2022-12-13T15:09:10","date_gmt":"2022-12-13T20:09:10","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=37886"},"modified":"2025-10-29T09:38:16","modified_gmt":"2025-10-29T13:38:16","slug":"swift-pitch-predicates","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2022\/12\/13\/swift-pitch-predicates\/","title":{"rendered":"Swift Pitch: Predicates"},"content":{"rendered":"<p><a href=\"https:\/\/forums.swift.org\/t\/pitch-swift-predicates\/62000\">Jeremy Schonfeld<\/a>:<\/p>\n<blockquote cite=\"https:\/\/forums.swift.org\/t\/pitch-swift-predicates\/62000\">\n<p>We propose creating a new value type, <code>Predicate<\/code>, 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 design <code>Predicate<\/code> to be type safe, readily archivable and <code>Sendable<\/code>, and integrated with Swift development environments.<\/p>\n<\/blockquote>\n<p>Aside from type-safety with respect to the object being tested, this could also potentially address the problem where it&rsquo;s not clear which APIs support which types of <code>NSPredicate<\/code>s.<\/p>\n\n<p><a href=\"https:\/\/gist.github.com\/jmschonfeld\/6821392a968a1a1a42aba3c96d333239\">Debbie Goldsmith and Jeremy Schonfeld<\/a>:<\/p>\n<blockquote cite=\"https:\/\/gist.github.com\/jmschonfeld\/6821392a968a1a1a42aba3c96d333239\"><p>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.<\/p><\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2022\/12\/12\/the-swifty-future-of-foundation\/\">The Swifty Future of Foundation<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2022\/10\/17\/a-possible-vision-for-macros-in-swift\/\">A Possible Vision for Macros in Swift<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Jeremy Schonfeld: 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 design Predicate to be type safe, readily archivable and Sendable, and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2022-12-13T20:09:12Z","apple_news_api_id":"48c69737-7cb1-4e7e-a760-d9993fe0eaed","apple_news_api_modified_at":"2025-10-29T13:38:19Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAA==","apple_news_api_share_url":"https:\/\/apple.news\/ASMaXN3yxTn6nYNmZP-Dq7Q","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[109,46,71,1042,2854,901],"class_list":["post-37886","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-coredata","tag-languagedesign","tag-programming","tag-spotlight","tag-swift-foundation","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/37886","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=37886"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/37886\/revisions"}],"predecessor-version":[{"id":37887,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/37886\/revisions\/37887"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=37886"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=37886"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=37886"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}